1.22
This commit is contained in:
Generated
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
import { IBellParams } from '../interface/index';
|
||||
export declare class BellContext {
|
||||
private _bellContext;
|
||||
private _isMuteBell;
|
||||
private _calleeBellFilePath;
|
||||
private _callRole;
|
||||
private _callStatus;
|
||||
constructor();
|
||||
setBellSrc(): void;
|
||||
setBellProperties(bellParams: IBellParams): void;
|
||||
play(): Promise<void>;
|
||||
stop(): Promise<void>;
|
||||
setBellMute(enable: boolean): Promise<void>;
|
||||
destroy(): void;
|
||||
}
|
||||
Generated
Vendored
+106
@@ -0,0 +1,106 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.BellContext = void 0;
|
||||
const index_1 = require("../const/index");
|
||||
const common_utils_1 = require("../utils/common-utils");
|
||||
const DEFAULT_CALLER_BELL_FILEPATH = '/TUICallKit/static/phone_dialing.mp3';
|
||||
const DEFAULT_CALLEE_BELL_FILEPATH = '/TUICallKit/static/phone_ringing.mp3';
|
||||
class BellContext {
|
||||
constructor() {
|
||||
this._bellContext = null;
|
||||
this._isMuteBell = false;
|
||||
this._calleeBellFilePath = DEFAULT_CALLEE_BELL_FILEPATH;
|
||||
this._callRole = index_1.CallRole.UNKNOWN;
|
||||
this._callStatus = index_1.CallStatus.IDLE;
|
||||
// @ts-ignore
|
||||
this._bellContext = wx.createInnerAudioContext();
|
||||
this._bellContext.loop = true;
|
||||
}
|
||||
setBellSrc() {
|
||||
// @ts-ignore
|
||||
const fs = wx.getFileSystemManager();
|
||||
try {
|
||||
let playBellFilePath = DEFAULT_CALLER_BELL_FILEPATH;
|
||||
if (this._callRole === index_1.CallRole.CALLEE) {
|
||||
playBellFilePath = this._calleeBellFilePath || DEFAULT_CALLEE_BELL_FILEPATH;
|
||||
}
|
||||
fs.readFileSync(playBellFilePath, 'utf8', 0);
|
||||
this._bellContext.src = playBellFilePath;
|
||||
}
|
||||
catch (error) {
|
||||
console.warn(`${index_1.NAME.PREFIX}Failed to setBellSrc, ${error}`);
|
||||
}
|
||||
}
|
||||
setBellProperties(bellParams) {
|
||||
this._callRole = bellParams.callRole || this._callRole;
|
||||
this._callStatus = bellParams.callStatus || this._callStatus;
|
||||
this._calleeBellFilePath = bellParams.calleeBellFilePath || this._calleeBellFilePath;
|
||||
// undefined/false || isMuteBell => isMuteBell (不符合预期)
|
||||
this._isMuteBell = (0, common_utils_1.isUndefined)(bellParams.isMuteBell) ? this._isMuteBell : bellParams.isMuteBell;
|
||||
}
|
||||
play() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
if (this._callStatus !== index_1.CallStatus.CALLING) {
|
||||
return;
|
||||
}
|
||||
this.setBellSrc();
|
||||
if (this._callRole === index_1.CallRole.CALLEE && !this._isMuteBell) {
|
||||
yield this._bellContext.play();
|
||||
}
|
||||
if (this._callRole === index_1.CallRole.CALLER) {
|
||||
yield this._bellContext.play();
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
console.warn(`${index_1.NAME.PREFIX}Failed to play audio file, ${error}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
stop() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
this._bellContext.stop();
|
||||
}
|
||||
catch (error) {
|
||||
console.warn(`${index_1.NAME.PREFIX}Failed to stop audio file, ${error}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
setBellMute(enable) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (this._callStatus !== index_1.CallStatus.CALLING && this._callRole !== index_1.CallRole.CALLEE) {
|
||||
return;
|
||||
}
|
||||
if (enable) {
|
||||
yield this.stop();
|
||||
}
|
||||
else {
|
||||
yield this.play();
|
||||
}
|
||||
});
|
||||
}
|
||||
destroy() {
|
||||
try {
|
||||
this._isMuteBell = false;
|
||||
this._calleeBellFilePath = '';
|
||||
this._callRole = index_1.CallRole.UNKNOWN;
|
||||
this._callStatus = index_1.CallStatus.IDLE;
|
||||
this._bellContext.destroy();
|
||||
this._bellContext = null;
|
||||
}
|
||||
catch (error) {
|
||||
console.warn(`${index_1.NAME.PREFIX}Failed to destroy, ${error}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.BellContext = BellContext;
|
||||
Generated
Vendored
+97
@@ -0,0 +1,97 @@
|
||||
import { ITUICallService, ICallParams, IGroupCallParams, ICallbackParam, ISelfInfoParams, IInviteUserParams, IJoinInGroupCallParams, IInitParams } from '../interface/ICallService';
|
||||
import { LanguageType, LOG_LEVEL, VideoDisplayMode, VideoResolution } from '../const/index';
|
||||
import { ITUIGlobal } from '../interface/ITUIGlobal';
|
||||
import { ITUIStore } from '../interface/ITUIStore';
|
||||
declare const TUIGlobal: ITUIGlobal;
|
||||
declare const TUIStore: ITUIStore;
|
||||
export { TUIGlobal, TUIStore };
|
||||
export default class TUICallService implements ITUICallService {
|
||||
static instance: TUICallService;
|
||||
_tuiCallEngine: any;
|
||||
private _tim;
|
||||
private _TUICore;
|
||||
private _timerId;
|
||||
private _bellContext;
|
||||
constructor();
|
||||
static getInstance(): TUICallService;
|
||||
init(params: IInitParams): Promise<void>;
|
||||
destroyed(): Promise<void>;
|
||||
call(callParams: ICallParams): Promise<void>;
|
||||
groupCall(groupCallParams: IGroupCallParams): Promise<void>;
|
||||
inviteUser(params: IInviteUserParams): Promise<void>;
|
||||
joinInGroupCall(params: IJoinInGroupCallParams): Promise<void>;
|
||||
getTUICallEngineInstance(): any;
|
||||
setLogLevel(level: LOG_LEVEL): void;
|
||||
setLanguage(language: LanguageType): void;
|
||||
enableFloatWindow(enable: boolean): void;
|
||||
setSelfInfo(params: ISelfInfoParams): Promise<void>;
|
||||
setCallingBell(filePath?: string): Promise<void>;
|
||||
enableMuteMode(enable: boolean): Promise<void>;
|
||||
accept(): Promise<void>;
|
||||
hangup(): Promise<void>;
|
||||
reject(): Promise<void>;
|
||||
openCamera(videoViewDomID: string): Promise<void>;
|
||||
closeCamera(): Promise<void>;
|
||||
openMicrophone(): Promise<void>;
|
||||
closeMicrophone(): Promise<void>;
|
||||
switchScreen(userId: string): void;
|
||||
switchCallMediaType(): Promise<void>;
|
||||
switchCamera(): Promise<void>;
|
||||
setSoundMode(type?: string): void;
|
||||
getTim(): any;
|
||||
private _addListenTuiCallEngineEvent;
|
||||
private _removeListenTuiCallEngineEvent;
|
||||
private _handleError;
|
||||
private _handleNewInvitationReceived;
|
||||
private _handleUserAccept;
|
||||
private _handleUserEnter;
|
||||
private _callerChangeToConnected;
|
||||
private _handleUserLeave;
|
||||
private _unNormalEventsManager;
|
||||
private _handleInviteeReject;
|
||||
private _handleNoResponse;
|
||||
private _handleLineBusy;
|
||||
private _handleCallingCancel;
|
||||
private _handleCallingEnd;
|
||||
private _handleSDKReady;
|
||||
private _handleKickedOut;
|
||||
private _handleCallTypeChange;
|
||||
private _messageSentByMe;
|
||||
private _handleUserUpdate;
|
||||
private _handleCallError;
|
||||
beforeCalling: ((...args: any[]) => void) | undefined;
|
||||
afterCalling: ((...args: any[]) => void) | undefined;
|
||||
onMinimized: ((...args: any[]) => void) | undefined;
|
||||
onMessageSentByMe: ((...args: any[]) => void) | undefined;
|
||||
kickedOut: ((...args: any[]) => void) | undefined;
|
||||
statusChanged: ((...args: any[]) => void) | undefined;
|
||||
setCallback(params: ICallbackParam): void;
|
||||
toggleMinimize(): void;
|
||||
private _executeExternalBeforeCalling;
|
||||
private _executeExternalAfterCalling;
|
||||
setVideoDisplayMode(displayMode: VideoDisplayMode): void;
|
||||
setVideoResolution(resolution: VideoResolution): Promise<void>;
|
||||
private _handleExceptionExit;
|
||||
private _setLocalUserInfoAudioVideoAvailable;
|
||||
private _updateCallStoreBeforeCall;
|
||||
private _updateCallStoreAfterCall;
|
||||
private _resetCurrentDevice;
|
||||
private _resetCallStore;
|
||||
private _noDevicePermissionToast;
|
||||
private _startTimer;
|
||||
private _updateCallDuration;
|
||||
private _stopTimer;
|
||||
private _deleteRemoteUser;
|
||||
private _analyzeEventData;
|
||||
getGroupMemberList(count: number, offset: number): Promise<any>;
|
||||
getGroupProfile(): Promise<any>;
|
||||
private _handleCallStatusChange;
|
||||
private _watchTUIStore;
|
||||
private _unwatchTUIStore;
|
||||
bindTUICore(TUICore: any): void;
|
||||
private _callTUIService;
|
||||
onNotifyEvent(eventName: string, subKey: string): Promise<void>;
|
||||
onCall(method: String, params: any): Promise<void>;
|
||||
private _handleTUICoreOnClick;
|
||||
onGetExtension(extensionID: string, params: any): any[];
|
||||
}
|
||||
Generated
Vendored
+1147
File diff suppressed because it is too large
Load Diff
Generated
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
import { CallMediaType, CallStatus } from '../const/index';
|
||||
export declare function initialUI(): void;
|
||||
export declare function checkRunPlatform(): void;
|
||||
export declare function initAndCheckRunEnv(): void;
|
||||
export declare function beforeCall(type: CallMediaType, that: any): Promise<CallStatus.IDLE | CallStatus.CALLING>;
|
||||
export declare function handlePackageError(error: any): void;
|
||||
Generated
Vendored
+76
@@ -0,0 +1,76 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.handlePackageError = exports.beforeCall = exports.initAndCheckRunEnv = exports.checkRunPlatform = exports.initialUI = void 0;
|
||||
const index_1 = require("../const/index");
|
||||
function initialUI() {
|
||||
// 收起键盘
|
||||
// @ts-ignore
|
||||
wx.hideKeyboard({
|
||||
complete: () => { },
|
||||
});
|
||||
}
|
||||
exports.initialUI = initialUI;
|
||||
;
|
||||
// 检测运行时环境, 当是微信开发者工具时, 提示用户需要手机调试
|
||||
function checkRunPlatform() {
|
||||
// @ts-ignore
|
||||
const systemInfo = wx.getSystemInfoSync();
|
||||
if (systemInfo.platform === 'devtools') {
|
||||
// 当前运行在微信开发者工具里
|
||||
// @ts-ignore
|
||||
wx.showModal({
|
||||
icon: 'none',
|
||||
title: '运行环境提醒',
|
||||
content: '微信开发者工具不支持原生推拉流组件(即 <live-pusher> 和 <live-player> 标签),请使用真机调试或者扫码预览。',
|
||||
showCancel: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.checkRunPlatform = checkRunPlatform;
|
||||
;
|
||||
function initAndCheckRunEnv() {
|
||||
initialUI(); // miniProgram 收起键盘, 隐藏 tabBar
|
||||
checkRunPlatform(); // miniProgram 检测运行时环境
|
||||
}
|
||||
exports.initAndCheckRunEnv = initAndCheckRunEnv;
|
||||
function beforeCall(type, that) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
initAndCheckRunEnv();
|
||||
// 检查设备权限
|
||||
const deviceMap = {
|
||||
microphone: true,
|
||||
camera: type === index_1.CallMediaType.VIDEO,
|
||||
};
|
||||
const hasDevicePermission = yield that._tuiCallEngine.deviceCheck(deviceMap); // miniProgram 检查设备权限
|
||||
return hasDevicePermission ? index_1.CallStatus.CALLING : index_1.CallStatus.IDLE;
|
||||
}
|
||||
catch (error) {
|
||||
console.debug(error);
|
||||
return index_1.CallStatus.IDLE;
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.beforeCall = beforeCall;
|
||||
// 套餐问题提示, 小程序最低需要群组通话版, 1v1 通话版本使用 TRTC 就会报错
|
||||
function handlePackageError(error) {
|
||||
if ((error === null || error === void 0 ? void 0 : error.code) === -1002) {
|
||||
// @ts-ignore
|
||||
wx.showModal({
|
||||
icon: 'none',
|
||||
title: 'error',
|
||||
content: (error === null || error === void 0 ? void 0 : error.message) || '',
|
||||
showCancel: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.handlePackageError = handlePackageError;
|
||||
Generated
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
import { IUserInfo } from '../interface/ICallService';
|
||||
import { ITUIStore } from '../interface/ITUIStore';
|
||||
export declare function setDefaultUserInfo(userId: string, domId?: string): IUserInfo;
|
||||
export declare function getMyProfile(myselfUserId: string, tim: any, TUIStore: any): Promise<IUserInfo>;
|
||||
export declare function getRemoteUserProfile(userIdList: Array<string>, tim: any, TUIStore: any): Promise<any>;
|
||||
export declare function generateText(TUIStore: ITUIStore, key: string, prefix?: string, suffix?: string): string;
|
||||
export declare function generateStatusChangeText(TUIStore: ITUIStore): string;
|
||||
export declare function getGroupMemberList(groupID: string, tim: any, count: any, offset: any): Promise<any>;
|
||||
export declare function getGroupProfile(groupID: string, tim: any): Promise<any>;
|
||||
Generated
Vendored
+167
@@ -0,0 +1,167 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getGroupProfile = exports.getGroupMemberList = exports.generateStatusChangeText = exports.generateText = exports.getRemoteUserProfile = exports.getMyProfile = exports.setDefaultUserInfo = void 0;
|
||||
const index_1 = require("../const/index");
|
||||
const index_2 = require("../locales/index");
|
||||
// 设置默认的 UserInfo 信息
|
||||
function setDefaultUserInfo(userId, domId) {
|
||||
const userInfo = {
|
||||
userId,
|
||||
nick: '',
|
||||
avatar: '',
|
||||
remark: '',
|
||||
displayUserInfo: '',
|
||||
isAudioAvailable: false,
|
||||
isVideoAvailable: false,
|
||||
isEnter: false,
|
||||
domId: domId || userId,
|
||||
};
|
||||
return domId ? userInfo : Object.assign(Object.assign({}, userInfo), { isEnter: false }); // localUserInfo 没有 isEnter, remoteUserInfoList 有 isEnter
|
||||
}
|
||||
exports.setDefaultUserInfo = setDefaultUserInfo;
|
||||
// 获取个人用户信息
|
||||
function getMyProfile(myselfUserId, tim, TUIStore) {
|
||||
var _a, _b, _c;
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let localUserInfo = setDefaultUserInfo(myselfUserId, index_1.NAME.LOCAL_VIDEO);
|
||||
try {
|
||||
if (!tim)
|
||||
return localUserInfo;
|
||||
const res = yield tim.getMyProfile();
|
||||
const currentLocalUserInfo = TUIStore === null || TUIStore === void 0 ? void 0 : TUIStore.getData(index_1.StoreName.CALL, index_1.NAME.LOCAL_USER_INFO); // localUserInfo may have been updated
|
||||
if ((res === null || res === void 0 ? void 0 : res.code) === 0) {
|
||||
localUserInfo = Object.assign(Object.assign(Object.assign({}, localUserInfo), currentLocalUserInfo), { userId: (_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.userID, nick: (_b = res === null || res === void 0 ? void 0 : res.data) === null || _b === void 0 ? void 0 : _b.nick, avatar: (_c = res === null || res === void 0 ? void 0 : res.data) === null || _c === void 0 ? void 0 : _c.avatar });
|
||||
}
|
||||
return localUserInfo;
|
||||
}
|
||||
catch (error) {
|
||||
console.error(`${index_1.NAME.PREFIX}getMyProfile failed, error: ${error}.`);
|
||||
return localUserInfo;
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.getMyProfile = getMyProfile;
|
||||
// 获取远端用户列表信息
|
||||
function getRemoteUserProfile(userIdList, tim, TUIStore) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let remoteUserInfoList = userIdList.map((userId) => setDefaultUserInfo(userId));
|
||||
try {
|
||||
if (!tim)
|
||||
return remoteUserInfoList;
|
||||
const res = yield tim.getFriendProfile({ userIDList: userIdList });
|
||||
if (res.code === 0) {
|
||||
const { friendList = [], failureUserIDList = [] } = res.data;
|
||||
let unFriendList = failureUserIDList.map((obj) => obj.userID);
|
||||
if (failureUserIDList.length > 0) {
|
||||
const res = yield tim.getUserProfile({ userIDList: failureUserIDList.map((obj) => obj.userID) });
|
||||
if ((res === null || res === void 0 ? void 0 : res.code) === 0) {
|
||||
unFriendList = (res === null || res === void 0 ? void 0 : res.data) || [];
|
||||
}
|
||||
}
|
||||
const currentRemoteUserInfoList = TUIStore === null || TUIStore === void 0 ? void 0 : TUIStore.getData(index_1.StoreName.CALL, index_1.NAME.REMOTE_USER_INFO_LIST); // remoteUserInfoList may have been updated
|
||||
const tempFriendIdList = friendList.map((obj) => obj.userID);
|
||||
const tempUnFriendIdList = unFriendList.map((obj) => obj.userID);
|
||||
remoteUserInfoList = userIdList.map((userId) => {
|
||||
var _a, _b, _c, _d, _e, _f, _g;
|
||||
const defaultUserInfo = setDefaultUserInfo(userId);
|
||||
const friendListIndex = tempFriendIdList.indexOf(userId);
|
||||
const unFriendListIndex = tempUnFriendIdList.indexOf(userId);
|
||||
let remark = '';
|
||||
let nick = '';
|
||||
let displayUserInfo = '';
|
||||
let avatar = '';
|
||||
if (friendListIndex !== -1) {
|
||||
remark = ((_a = friendList[friendListIndex]) === null || _a === void 0 ? void 0 : _a.remark) || '';
|
||||
nick = ((_c = (_b = friendList[friendListIndex]) === null || _b === void 0 ? void 0 : _b.profile) === null || _c === void 0 ? void 0 : _c.nick) || '';
|
||||
displayUserInfo = remark || nick || defaultUserInfo.userId || '';
|
||||
avatar = ((_e = (_d = friendList[friendListIndex]) === null || _d === void 0 ? void 0 : _d.profile) === null || _e === void 0 ? void 0 : _e.avatar) || '';
|
||||
}
|
||||
if (unFriendListIndex !== -1) {
|
||||
nick = ((_f = unFriendList[unFriendListIndex]) === null || _f === void 0 ? void 0 : _f.nick) || '';
|
||||
displayUserInfo = nick || defaultUserInfo.userId || '';
|
||||
avatar = ((_g = unFriendList[unFriendListIndex]) === null || _g === void 0 ? void 0 : _g.avatar) || '';
|
||||
}
|
||||
const userInfo = currentRemoteUserInfoList.find(subObj => subObj.userId === userId) || {};
|
||||
return Object.assign(Object.assign(Object.assign({}, defaultUserInfo), userInfo), { remark, nick, displayUserInfo, avatar });
|
||||
});
|
||||
}
|
||||
return remoteUserInfoList;
|
||||
}
|
||||
catch (error) {
|
||||
console.error(`${index_1.NAME.PREFIX}getRemoteUserProfile failed, error: ${error}.`);
|
||||
return remoteUserInfoList;
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.getRemoteUserProfile = getRemoteUserProfile;
|
||||
// 生成弹框提示文案
|
||||
function generateText(TUIStore, key, prefix, suffix) {
|
||||
const isGroup = TUIStore.getData(index_1.StoreName.CALL, index_1.NAME.IS_GROUP);
|
||||
let callTips = `${(0, index_2.t)(key)}`;
|
||||
if (isGroup) {
|
||||
callTips = prefix ? `${prefix} ${callTips}` : callTips;
|
||||
callTips = suffix ? `${callTips} ${suffix}` : callTips;
|
||||
}
|
||||
return callTips;
|
||||
}
|
||||
exports.generateText = generateText;
|
||||
// 生成 statusChange 抛出的字符串
|
||||
function generateStatusChangeText(TUIStore) {
|
||||
const callStatus = TUIStore.getData(index_1.StoreName.CALL, index_1.NAME.CALL_STATUS);
|
||||
if (callStatus === index_1.CallStatus.IDLE) {
|
||||
return index_1.StatusChange.IDLE;
|
||||
}
|
||||
const isGroup = TUIStore.getData(index_1.StoreName.CALL, index_1.NAME.IS_GROUP);
|
||||
if (callStatus === index_1.CallStatus.CALLING) {
|
||||
return isGroup ? index_1.StatusChange.DIALING_GROUP : index_1.StatusChange.DIALING_C2C;
|
||||
}
|
||||
const callMediaType = TUIStore.getData(index_1.StoreName.CALL, index_1.NAME.CALL_MEDIA_TYPE);
|
||||
if (isGroup) {
|
||||
return callMediaType === index_1.CallMediaType.AUDIO ? index_1.StatusChange.CALLING_GROUP_AUDIO : index_1.StatusChange.CALLING_GROUP_VIDEO;
|
||||
}
|
||||
return callMediaType === index_1.CallMediaType.AUDIO ? index_1.StatusChange.CALLING_C2C_AUDIO : index_1.StatusChange.CALLING_C2C_VIDEO;
|
||||
}
|
||||
exports.generateStatusChangeText = generateStatusChangeText;
|
||||
// 获取群组[offset, count + offset]区间成员
|
||||
function getGroupMemberList(groupID, tim, count, offset) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let groupMemberList = [];
|
||||
try {
|
||||
const res = yield tim.getGroupMemberList({ groupID, count, offset });
|
||||
if (res.code === 0) {
|
||||
return res.data.memberList || groupMemberList;
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
console.error(`${index_1.NAME.PREFIX}getGroupMember failed, error: ${error}.`);
|
||||
return groupMemberList;
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.getGroupMemberList = getGroupMemberList;
|
||||
// 获取 IM 群信息
|
||||
function getGroupProfile(groupID, tim) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
let groupProfile = {};
|
||||
try {
|
||||
const res = yield tim.getGroupProfile({ groupID });
|
||||
if (res.code === 0) {
|
||||
return res.data.group || groupProfile;
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
console.error(`${index_1.NAME.PREFIX}getGroupProfile failed, error: ${error}.`);
|
||||
return groupProfile;
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.getGroupProfile = getGroupProfile;
|
||||
Generated
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
import { ITUIGlobal } from '../interface/ITUIGlobal';
|
||||
export default class TUIGlobal implements ITUIGlobal {
|
||||
static instance: TUIGlobal;
|
||||
global: any;
|
||||
isPC: boolean;
|
||||
isH5: boolean;
|
||||
isWeChat: boolean;
|
||||
isApp: boolean;
|
||||
isUniPlatform: boolean;
|
||||
isOfficial: boolean;
|
||||
isWIN: boolean;
|
||||
isMAC: boolean;
|
||||
constructor();
|
||||
/**
|
||||
* 获取 TUIGlobal 实例
|
||||
* @returns {TUIGlobal}
|
||||
*/
|
||||
static getInstance(): TUIGlobal;
|
||||
initEnv(): void;
|
||||
initOfficial(SDKAppID: number): void;
|
||||
}
|
||||
Generated
Vendored
+40
@@ -0,0 +1,40 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const env_1 = require("../utils/env");
|
||||
class TUIGlobal {
|
||||
constructor() {
|
||||
this.global = env_1.APP_NAMESPACE;
|
||||
this.isPC = false;
|
||||
this.isH5 = false;
|
||||
this.isWeChat = false;
|
||||
this.isApp = false;
|
||||
this.isUniPlatform = false;
|
||||
this.isOfficial = false;
|
||||
this.isWIN = false;
|
||||
this.isMAC = false;
|
||||
this.initEnv();
|
||||
}
|
||||
/**
|
||||
* 获取 TUIGlobal 实例
|
||||
* @returns {TUIGlobal}
|
||||
*/
|
||||
static getInstance() {
|
||||
if (!TUIGlobal.instance) {
|
||||
TUIGlobal.instance = new TUIGlobal();
|
||||
}
|
||||
return TUIGlobal.instance;
|
||||
}
|
||||
initEnv() {
|
||||
this.isPC = env_1.IS_PC;
|
||||
this.isH5 = env_1.IS_H5;
|
||||
this.isWeChat = env_1.IN_WX_MINI_APP;
|
||||
this.isApp = env_1.IN_UNI_NATIVE_APP && !env_1.IN_WX_MINI_APP; // uniApp 打包小程序时 IN_UNI_NATIVE_APP 为 true,所以此处需要增加条件
|
||||
this.isUniPlatform = env_1.IN_UNI_APP;
|
||||
this.isWIN = env_1.IS_WIN;
|
||||
this.isMAC = env_1.IS_MAC;
|
||||
}
|
||||
initOfficial(SDKAppID) {
|
||||
this.isOfficial = (SDKAppID === 1400187352 || SDKAppID === 1400188366);
|
||||
}
|
||||
}
|
||||
exports.default = TUIGlobal;
|
||||
Generated
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
import { ICallStore } from '../interface/ICallStore';
|
||||
export default class CallStore {
|
||||
defaultStore: ICallStore;
|
||||
store: ICallStore;
|
||||
update(key: keyof ICallStore, data: any): void;
|
||||
getData(key: string | undefined): any;
|
||||
reset(keyList?: Array<string>): void;
|
||||
}
|
||||
Generated
Vendored
+62
@@ -0,0 +1,62 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const index_1 = require("../const/index");
|
||||
const common_utils_1 = require("../utils/common-utils");
|
||||
class CallStore {
|
||||
constructor() {
|
||||
this.defaultStore = {
|
||||
callStatus: index_1.CallStatus.IDLE,
|
||||
callRole: index_1.CallRole.UNKNOWN,
|
||||
callMediaType: index_1.CallMediaType.UNKNOWN,
|
||||
localUserInfo: { userId: '' },
|
||||
remoteUserInfoList: [],
|
||||
callerUserInfo: { userId: '' },
|
||||
isGroup: false,
|
||||
callDuration: '00:00:00',
|
||||
callTips: '',
|
||||
toastInfo: { text: '' },
|
||||
isMinimized: false,
|
||||
enableFloatWindow: false,
|
||||
bigScreenUserId: '',
|
||||
language: (0, common_utils_1.getLanguage)(),
|
||||
isClickable: false,
|
||||
deviceList: { cameraList: [], microphoneList: [], currentCamera: {}, currentMicrophone: {} },
|
||||
showPermissionTip: false,
|
||||
groupID: '',
|
||||
roomID: 0,
|
||||
// TUICallKit 组件上的属性
|
||||
displayMode: index_1.VideoDisplayMode.COVER,
|
||||
videoResolution: index_1.VideoResolution.RESOLUTION_480P,
|
||||
showSelectUser: false,
|
||||
// 小程序相关属性
|
||||
pusher: {},
|
||||
player: [],
|
||||
isEarPhone: false, // 是否是听筒, 默认: false
|
||||
};
|
||||
this.store = Object.assign({}, this.defaultStore);
|
||||
}
|
||||
;
|
||||
update(key, data) {
|
||||
switch (key) {
|
||||
// case 'callTips':
|
||||
// break;
|
||||
default:
|
||||
// resolve "Type 'any' is not assignable to type 'never'.ts", ref: https://github.com/microsoft/TypeScript/issues/31663
|
||||
this.store[key] = data;
|
||||
}
|
||||
}
|
||||
getData(key) {
|
||||
if (!key)
|
||||
return this.store;
|
||||
return this.store[key];
|
||||
}
|
||||
// reset call store
|
||||
reset(keyList = []) {
|
||||
if (keyList.length === 0) {
|
||||
keyList = Object.keys(this.store);
|
||||
}
|
||||
const resetToDefault = keyList.reduce((acc, key) => (Object.assign(Object.assign({}, acc), { [key]: this.defaultStore[key] })), {});
|
||||
this.store = Object.assign(Object.assign(Object.assign({}, this.defaultStore), this.store), resetToDefault);
|
||||
}
|
||||
}
|
||||
exports.default = CallStore;
|
||||
Generated
Vendored
+50
@@ -0,0 +1,50 @@
|
||||
import { ITUIStore, IOptions, Task } from '../interface/ITUIStore';
|
||||
import { StoreName } from '../const/index';
|
||||
export default class TUIStore implements ITUIStore {
|
||||
static instance: TUIStore;
|
||||
task: Task;
|
||||
private storeMap;
|
||||
private timerId;
|
||||
constructor();
|
||||
/**
|
||||
* 获取 TUIStore 实例
|
||||
* @returns {TUIStore}
|
||||
*/
|
||||
static getInstance(): TUIStore;
|
||||
/**
|
||||
* UI 组件注册监听回调
|
||||
* @param {StoreName} storeName store 名称
|
||||
* @param {IOptions} options 监听信息
|
||||
* @param {Object} params 扩展参数
|
||||
* @param {String} params.notifyRangeWhenWatch 注册时监听时的通知范围, 'all' - 通知所有注册该 key 的监听; 'myself' - 通知本次注册该 key 的监听; 默认不通知
|
||||
*/
|
||||
watch(storeName: StoreName, options: IOptions, params?: any): void;
|
||||
/**
|
||||
* UI 取消组件监听回调
|
||||
* @param {StoreName} storeName store 名称
|
||||
* @param {IOptions} options 监听信息,包含需要取消的回掉等
|
||||
*/
|
||||
unwatch(storeName: StoreName, options: IOptions): void;
|
||||
/**
|
||||
* 通用 store 数据更新,messageList 的变更需要单独处理
|
||||
* @param {StoreName} storeName store 名称
|
||||
* @param {string} key 变更的 key
|
||||
* @param {unknown} data 变更的数据
|
||||
*/
|
||||
update(storeName: StoreName, key: string, data: unknown): void;
|
||||
/**
|
||||
* 获取 Store 数据
|
||||
* @param {StoreName} storeName store 名称
|
||||
* @param {string} key 待获取的 key
|
||||
* @returns {Any}
|
||||
*/
|
||||
getData(storeName: StoreName, key: string): any;
|
||||
/**
|
||||
* UI 组件注册监听回调
|
||||
* @param {StoreName} storeName store 名称
|
||||
* @param {string} key 变更的 key
|
||||
*/
|
||||
private notify;
|
||||
reset(storeName: StoreName, keyList?: Array<string>, isNotificationNeeded?: boolean): void;
|
||||
updateStore(params: any, name?: StoreName): void;
|
||||
}
|
||||
Generated
Vendored
+155
@@ -0,0 +1,155 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const index_1 = require("../const/index");
|
||||
const callStore_1 = __importDefault(require("./callStore"));
|
||||
const common_utils_1 = require("../utils/common-utils");
|
||||
class TUIStore {
|
||||
constructor() {
|
||||
this.timerId = -1;
|
||||
this.storeMap = {
|
||||
[index_1.StoreName.CALL]: new callStore_1.default(),
|
||||
};
|
||||
// todo 此处后续优化结构后调整
|
||||
this.task = {}; // 保存监听回调列表
|
||||
}
|
||||
/**
|
||||
* 获取 TUIStore 实例
|
||||
* @returns {TUIStore}
|
||||
*/
|
||||
static getInstance() {
|
||||
if (!TUIStore.instance) {
|
||||
TUIStore.instance = new TUIStore();
|
||||
}
|
||||
return TUIStore.instance;
|
||||
}
|
||||
/**
|
||||
* UI 组件注册监听回调
|
||||
* @param {StoreName} storeName store 名称
|
||||
* @param {IOptions} options 监听信息
|
||||
* @param {Object} params 扩展参数
|
||||
* @param {String} params.notifyRangeWhenWatch 注册时监听时的通知范围, 'all' - 通知所有注册该 key 的监听; 'myself' - 通知本次注册该 key 的监听; 默认不通知
|
||||
*/
|
||||
watch(storeName, options, params) {
|
||||
if (!this.task[storeName]) {
|
||||
this.task[storeName] = {};
|
||||
}
|
||||
const watcher = this.task[storeName];
|
||||
Object.keys(options).forEach((key) => {
|
||||
const callback = options[key];
|
||||
if (!watcher[key]) {
|
||||
watcher[key] = new Map();
|
||||
}
|
||||
watcher[key].set(callback, 1);
|
||||
const { notifyRangeWhenWatch } = params || {};
|
||||
// 注册监听后, 通知所有注册该 key 的监听,使用 'all' 时要特别注意是否对其他地方的监听产生影响
|
||||
if (notifyRangeWhenWatch === index_1.NAME.ALL) {
|
||||
this.notify(storeName, key);
|
||||
}
|
||||
// 注册监听后, 仅通知自己本次监听该 key 的数据
|
||||
if (notifyRangeWhenWatch === index_1.NAME.MYSELF) {
|
||||
const data = this.getData(storeName, key);
|
||||
callback.call(this, data);
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* UI 取消组件监听回调
|
||||
* @param {StoreName} storeName store 名称
|
||||
* @param {IOptions} options 监听信息,包含需要取消的回掉等
|
||||
*/
|
||||
unwatch(storeName, options) {
|
||||
// todo 该接口暂未支持,unwatch掉同一类,如仅传入store注销掉该store下的所有callback,同样options仅传入key注销掉该key下的所有callback
|
||||
// options的callback function为必填参数,后续修改
|
||||
if (!this.task[storeName]) {
|
||||
return;
|
||||
}
|
||||
;
|
||||
// if (isString(options)) {
|
||||
// // 移除所有的监听
|
||||
// if (options === '*') {
|
||||
// const watcher = this.task[storeName];
|
||||
// Object.keys(watcher).forEach(key => {
|
||||
// watcher[key].clear();
|
||||
// });
|
||||
// } else {
|
||||
// console.warn(`${NAME.PREFIX}unwatch warning: options is ${options}`);
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
const watcher = this.task[storeName];
|
||||
Object.keys(options).forEach((key) => {
|
||||
watcher[key].delete(options[key]);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 通用 store 数据更新,messageList 的变更需要单独处理
|
||||
* @param {StoreName} storeName store 名称
|
||||
* @param {string} key 变更的 key
|
||||
* @param {unknown} data 变更的数据
|
||||
*/
|
||||
update(storeName, key, data) {
|
||||
var _a;
|
||||
// 基本数据类型时, 如果相等, 就不进行更新, 减少不必要的 notify
|
||||
if ((0, common_utils_1.isString)(data) || (0, common_utils_1.isNumber)(data) || (0, common_utils_1.isBoolean)(data)) {
|
||||
const currentData = this.storeMap[storeName]['store'][key]; // eslint-disable-line
|
||||
if (currentData === data)
|
||||
return;
|
||||
}
|
||||
(_a = this.storeMap[storeName]) === null || _a === void 0 ? void 0 : _a.update(key, data);
|
||||
this.notify(storeName, key);
|
||||
}
|
||||
/**
|
||||
* 获取 Store 数据
|
||||
* @param {StoreName} storeName store 名称
|
||||
* @param {string} key 待获取的 key
|
||||
* @returns {Any}
|
||||
*/
|
||||
getData(storeName, key) {
|
||||
var _a;
|
||||
return (_a = this.storeMap[storeName]) === null || _a === void 0 ? void 0 : _a.getData(key);
|
||||
}
|
||||
/**
|
||||
* UI 组件注册监听回调
|
||||
* @param {StoreName} storeName store 名称
|
||||
* @param {string} key 变更的 key
|
||||
*/
|
||||
notify(storeName, key) {
|
||||
if (!this.task[storeName]) {
|
||||
return;
|
||||
}
|
||||
const watcher = this.task[storeName];
|
||||
if (watcher[key]) {
|
||||
const callbackMap = watcher[key];
|
||||
const data = this.getData(storeName, key);
|
||||
for (const [callback] of callbackMap.entries()) {
|
||||
callback.call(this, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
reset(storeName, keyList = [], isNotificationNeeded = false) {
|
||||
if (storeName in this.storeMap) {
|
||||
const store = this.storeMap[storeName];
|
||||
// reset all
|
||||
if (keyList.length === 0) {
|
||||
keyList = Object.keys(store === null || store === void 0 ? void 0 : store.store);
|
||||
}
|
||||
store.reset(keyList);
|
||||
if (isNotificationNeeded) {
|
||||
keyList.forEach((key) => {
|
||||
this.notify(storeName, key);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
// 批量修改多个 key-value
|
||||
updateStore(params, name) {
|
||||
const storeName = name ? name : index_1.StoreName.CALL;
|
||||
Object.keys(params).forEach((key) => {
|
||||
this.update(storeName, key, params[key]);
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.default = TUIStore;
|
||||
Generated
Vendored
+93
@@ -0,0 +1,93 @@
|
||||
/**
|
||||
* @property {String} call 1v1 通话 + 群组通话
|
||||
* @property {String} CUSTOM 自定义 Store
|
||||
*/
|
||||
export declare enum StoreName {
|
||||
CALL = "call",
|
||||
CUSTOM = "custom"
|
||||
}
|
||||
/**
|
||||
* @property {String} idle 空闲
|
||||
* @property {String} connecting 呼叫等待中
|
||||
* @property {String} connected 通话中
|
||||
*/
|
||||
export declare enum CallMediaType {
|
||||
UNKNOWN = 0,
|
||||
AUDIO = 1,
|
||||
VIDEO = 2
|
||||
}
|
||||
/**
|
||||
* @property {String} caller 主叫
|
||||
* @property {String} callee 被叫
|
||||
*/
|
||||
export declare enum CallRole {
|
||||
UNKNOWN = "unknown",
|
||||
CALLEE = "callee",
|
||||
CALLER = "caller"
|
||||
}
|
||||
/**
|
||||
* @property {String} idle 空闲
|
||||
* @property {String} calling 呼叫等待中
|
||||
* @property {String} connected 通话中
|
||||
*/
|
||||
export declare enum CallStatus {
|
||||
IDLE = "idle",
|
||||
CALLING = "calling",
|
||||
CONNECTED = "connected"
|
||||
}
|
||||
/**
|
||||
* 视频画面显示模式
|
||||
* 播放视频流默认使用 cover 模式; 播放屏幕共享流默认使用 contain 模式。
|
||||
* @property {String} contain 优先保证视频内容全部显示。视频尺寸等比缩放,直至视频窗口的一边与视窗边框对齐。如果视频尺寸与显示视窗尺寸不一致,在保持长宽比的前提下,将视频进行缩放后填满视窗,缩放后的视频四周会有一圈黑边。
|
||||
* @property {String} cover 优先保证视窗被填满。视频尺寸等比缩放,直至整个视窗被视频填满。如果视频长宽与显示窗口不同,则视频流会按照显示视窗的比例进行周边裁剪或图像拉伸后填满视窗
|
||||
* @property {String} fill 保证视窗被填满的同时保证视频内容全部显示,但是不保证视频尺寸比例不变。视频的宽高会被拉伸至和视窗尺寸一致。(该选项值自 v4.12.1 开始支持)
|
||||
*/
|
||||
export declare enum VideoDisplayMode {
|
||||
CONTAIN = "contain",
|
||||
COVER = "cover",
|
||||
FILL = "fill"
|
||||
}
|
||||
/**
|
||||
* 视频分辨率
|
||||
* @property {String} 480p
|
||||
* @property {String} 720p
|
||||
* @property {String} 1080p
|
||||
*/
|
||||
export declare enum VideoResolution {
|
||||
RESOLUTION_480P = "480p",
|
||||
RESOLUTION_720P = "720p",
|
||||
RESOLUTION_1080P = "1080p"
|
||||
}
|
||||
export declare enum LanguageType {
|
||||
EN = "en",
|
||||
'ZH-CN' = "zh-cn",
|
||||
JA_JP = "ja_JP"
|
||||
}
|
||||
export type TDeviceList = {
|
||||
cameraList: any[];
|
||||
microphoneList: any[];
|
||||
currentCamera: any;
|
||||
currentMicrophone: any;
|
||||
};
|
||||
export declare const StatusChange: {
|
||||
readonly IDLE: "idle";
|
||||
readonly BE_INVITED: "be-invited";
|
||||
readonly DIALING_C2C: "dialing-c2c";
|
||||
readonly DIALING_GROUP: "dialing-group";
|
||||
readonly CALLING_C2C_AUDIO: "calling-c2c-audio";
|
||||
readonly CALLING_C2C_VIDEO: "calling-c2c-video";
|
||||
readonly CALLING_GROUP_AUDIO: "calling-group-audio";
|
||||
readonly CALLING_GROUP_VIDEO: "calling-group-video";
|
||||
};
|
||||
/**
|
||||
* @property {String} ear 听筒
|
||||
* @property {String} speaker 免提
|
||||
*/
|
||||
export declare enum AudioPlayBackDevice {
|
||||
EAR = "ear",
|
||||
SPEAKER = "speaker"
|
||||
}
|
||||
export declare enum DeviceType {
|
||||
MICROPHONE = "microphone",
|
||||
CAMERA = "camera"
|
||||
}
|
||||
Generated
Vendored
+104
@@ -0,0 +1,104 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.DeviceType = exports.AudioPlayBackDevice = exports.StatusChange = exports.LanguageType = exports.VideoResolution = exports.VideoDisplayMode = exports.CallStatus = exports.CallRole = exports.CallMediaType = exports.StoreName = void 0;
|
||||
/**
|
||||
* @property {String} call 1v1 通话 + 群组通话
|
||||
* @property {String} CUSTOM 自定义 Store
|
||||
*/
|
||||
var StoreName;
|
||||
(function (StoreName) {
|
||||
StoreName["CALL"] = "call";
|
||||
StoreName["CUSTOM"] = "custom";
|
||||
})(StoreName = exports.StoreName || (exports.StoreName = {}));
|
||||
/**
|
||||
* @property {String} idle 空闲
|
||||
* @property {String} connecting 呼叫等待中
|
||||
* @property {String} connected 通话中
|
||||
*/
|
||||
var CallMediaType;
|
||||
(function (CallMediaType) {
|
||||
CallMediaType[CallMediaType["UNKNOWN"] = 0] = "UNKNOWN";
|
||||
CallMediaType[CallMediaType["AUDIO"] = 1] = "AUDIO";
|
||||
CallMediaType[CallMediaType["VIDEO"] = 2] = "VIDEO";
|
||||
})(CallMediaType = exports.CallMediaType || (exports.CallMediaType = {}));
|
||||
/**
|
||||
* @property {String} caller 主叫
|
||||
* @property {String} callee 被叫
|
||||
*/
|
||||
var CallRole;
|
||||
(function (CallRole) {
|
||||
CallRole["UNKNOWN"] = "unknown";
|
||||
CallRole["CALLEE"] = "callee";
|
||||
CallRole["CALLER"] = "caller";
|
||||
})(CallRole = exports.CallRole || (exports.CallRole = {}));
|
||||
/**
|
||||
* @property {String} idle 空闲
|
||||
* @property {String} calling 呼叫等待中
|
||||
* @property {String} connected 通话中
|
||||
*/
|
||||
var CallStatus;
|
||||
(function (CallStatus) {
|
||||
CallStatus["IDLE"] = "idle";
|
||||
CallStatus["CALLING"] = "calling";
|
||||
CallStatus["CONNECTED"] = "connected";
|
||||
})(CallStatus = exports.CallStatus || (exports.CallStatus = {}));
|
||||
/**
|
||||
* 视频画面显示模式
|
||||
* 播放视频流默认使用 cover 模式; 播放屏幕共享流默认使用 contain 模式。
|
||||
* @property {String} contain 优先保证视频内容全部显示。视频尺寸等比缩放,直至视频窗口的一边与视窗边框对齐。如果视频尺寸与显示视窗尺寸不一致,在保持长宽比的前提下,将视频进行缩放后填满视窗,缩放后的视频四周会有一圈黑边。
|
||||
* @property {String} cover 优先保证视窗被填满。视频尺寸等比缩放,直至整个视窗被视频填满。如果视频长宽与显示窗口不同,则视频流会按照显示视窗的比例进行周边裁剪或图像拉伸后填满视窗
|
||||
* @property {String} fill 保证视窗被填满的同时保证视频内容全部显示,但是不保证视频尺寸比例不变。视频的宽高会被拉伸至和视窗尺寸一致。(该选项值自 v4.12.1 开始支持)
|
||||
*/
|
||||
var VideoDisplayMode;
|
||||
(function (VideoDisplayMode) {
|
||||
VideoDisplayMode["CONTAIN"] = "contain";
|
||||
VideoDisplayMode["COVER"] = "cover";
|
||||
VideoDisplayMode["FILL"] = "fill";
|
||||
})(VideoDisplayMode = exports.VideoDisplayMode || (exports.VideoDisplayMode = {}));
|
||||
/**
|
||||
* 视频分辨率
|
||||
* @property {String} 480p
|
||||
* @property {String} 720p
|
||||
* @property {String} 1080p
|
||||
*/
|
||||
var VideoResolution;
|
||||
(function (VideoResolution) {
|
||||
VideoResolution["RESOLUTION_480P"] = "480p";
|
||||
VideoResolution["RESOLUTION_720P"] = "720p";
|
||||
VideoResolution["RESOLUTION_1080P"] = "1080p";
|
||||
})(VideoResolution = exports.VideoResolution || (exports.VideoResolution = {}));
|
||||
// 支持的语言
|
||||
var LanguageType;
|
||||
(function (LanguageType) {
|
||||
LanguageType["EN"] = "en";
|
||||
LanguageType["ZH-CN"] = "zh-cn";
|
||||
LanguageType["JA_JP"] = "ja_JP";
|
||||
})(LanguageType = exports.LanguageType || (exports.LanguageType = {}));
|
||||
/* === 【原来 TUICallKit 对外暴露】=== */
|
||||
// 原来 web callKit 定义通知外部状态变更的变量, 对外暴露
|
||||
exports.StatusChange = {
|
||||
IDLE: "idle",
|
||||
BE_INVITED: "be-invited",
|
||||
DIALING_C2C: "dialing-c2c",
|
||||
DIALING_GROUP: "dialing-group",
|
||||
CALLING_C2C_AUDIO: "calling-c2c-audio",
|
||||
CALLING_C2C_VIDEO: "calling-c2c-video",
|
||||
CALLING_GROUP_AUDIO: "calling-group-audio",
|
||||
CALLING_GROUP_VIDEO: "calling-group-video",
|
||||
};
|
||||
/* === 【小程序使用】=== */
|
||||
/**
|
||||
* @property {String} ear 听筒
|
||||
* @property {String} speaker 免提
|
||||
*/
|
||||
var AudioPlayBackDevice;
|
||||
(function (AudioPlayBackDevice) {
|
||||
AudioPlayBackDevice["EAR"] = "ear";
|
||||
AudioPlayBackDevice["SPEAKER"] = "speaker";
|
||||
})(AudioPlayBackDevice = exports.AudioPlayBackDevice || (exports.AudioPlayBackDevice = {}));
|
||||
;
|
||||
var DeviceType;
|
||||
(function (DeviceType) {
|
||||
DeviceType["MICROPHONE"] = "microphone";
|
||||
DeviceType["CAMERA"] = "camera";
|
||||
})(DeviceType = exports.DeviceType || (exports.DeviceType = {}));
|
||||
Generated
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
export declare const ErrorCode: any;
|
||||
export declare const ErrorMessage: any;
|
||||
Generated
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ErrorMessage = exports.ErrorCode = void 0;
|
||||
// 错误码
|
||||
exports.ErrorCode = {
|
||||
SWITCH_TO_AUDIO_CALL_FAILED: 60001,
|
||||
SWITCH_TO_VIDEO_CALL_FAILED: 60002,
|
||||
MICROPHONE_UNAVAILABLE: 60003,
|
||||
CAMERA_UNAVAILABLE: 60004,
|
||||
BAN_DEVICE: 60005,
|
||||
NOT_SUPPORTED_WEBRTC: 60006,
|
||||
ERROR_BLACKLIST: 20007,
|
||||
};
|
||||
exports.ErrorMessage = {
|
||||
SWITCH_TO_AUDIO_CALL_FAILED: 'switchToAudioCall-call-failed',
|
||||
SWITCH_TO_VIDEO_CALL_FAILED: 'switchToVideoCall-call-failed',
|
||||
MICROPHONE_UNAVAILABLE: 'microphone-unavailable',
|
||||
CAMERA_UNAVAILABLE: 'camera-unavailable',
|
||||
BAN_DEVICE: 'ban-device',
|
||||
NOT_SUPPORTED_WEBRTC: 'not-supported-webrtc',
|
||||
ERROR_BLACKLIST: 'blacklist-user-tips'
|
||||
};
|
||||
Generated
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
export * from './call';
|
||||
export * from './error';
|
||||
export * from './log';
|
||||
export declare const CALL_DATA_KEY: any;
|
||||
export declare const NAME: any;
|
||||
export declare const AudioCallIcon = "https://web.sdk.qcloud.com/component/TUIKit/assets/call.png";
|
||||
export declare const VideoCallIcon = "https://web.sdk.qcloud.com/component/TUIKit/assets/call-video-reverse.svg";
|
||||
export declare const MAX_NUMBER_ROOM_ID = 2147483647;
|
||||
export declare enum PLATFORM {
|
||||
MAC = "mac",
|
||||
WIN = "win"
|
||||
}
|
||||
Generated
Vendored
+60
@@ -0,0 +1,60 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.PLATFORM = exports.MAX_NUMBER_ROOM_ID = exports.VideoCallIcon = exports.AudioCallIcon = exports.NAME = exports.CALL_DATA_KEY = void 0;
|
||||
__exportStar(require("./call"), exports);
|
||||
__exportStar(require("./error"), exports);
|
||||
__exportStar(require("./log"), exports);
|
||||
// import { keys } from 'ts-transformer-keys';
|
||||
// import { ICallStore } from '../interface/store';
|
||||
// console.warn('--> ', keys<ICallStore>())
|
||||
exports.CALL_DATA_KEY = {
|
||||
CALL_STATUS: 'callStatus',
|
||||
CALL_ROLE: 'callRole',
|
||||
CALL_MEDIA_TYPE: 'callMediaType',
|
||||
LOCAL_USER_INFO: 'localUserInfo',
|
||||
REMOTE_USER_INFO_LIST: 'remoteUserInfoList',
|
||||
CALLER_USER_INFO: 'callerUserInfo',
|
||||
IS_GROUP: 'isGroup',
|
||||
CALL_DURATION: 'callDuration',
|
||||
CALL_TIPS: 'callTips',
|
||||
TOAST_INFO: 'toastInfo',
|
||||
IS_MINIMIZED: 'isMinimized',
|
||||
ENABLE_FLOAT_WINDOW: 'enableFloatWindow',
|
||||
BIG_SCREEN_USER_ID: 'bigScreenUserId',
|
||||
LANGUAGE: 'language',
|
||||
IS_CLICKABLE: 'isClickable',
|
||||
DISPLAY_MODE: 'displayMode',
|
||||
VIDEO_RESOLUTION: 'videoResolution',
|
||||
PUSHER: 'pusher',
|
||||
PLAYER: 'player',
|
||||
IS_EAR_PHONE: 'isEarPhone',
|
||||
SHOW_PERMISSION_TIP: 'SHOW_PERMISSION_TIP',
|
||||
GROUP_ID: 'groupID',
|
||||
ROOM_ID: 'roomID',
|
||||
SHOW_SELECT_USER: 'showSelectUser',
|
||||
};
|
||||
exports.NAME = Object.assign({ PREFIX: '【CallService】', AUDIO: 'audio', VIDEO: 'video', LOCAL_VIDEO: 'localVideo', ERROR: 'error', TIMEOUT: 'timeout', RAF: 'raf', INTERVAL: 'interval', DEFAULT: 'default', BOOLEAN: 'boolean', STRING: 'string', NUMBER: 'number', OBJECT: 'object', ARRAY: 'array', FUNCTION: 'function', UNDEFINED: "undefined", ALL: 'all', MYSELF: 'myself', DEVICE_LIST: 'deviceList' }, exports.CALL_DATA_KEY);
|
||||
exports.AudioCallIcon = 'https://web.sdk.qcloud.com/component/TUIKit/assets/call.png';
|
||||
exports.VideoCallIcon = 'https://web.sdk.qcloud.com/component/TUIKit/assets/call-video-reverse.svg';
|
||||
exports.MAX_NUMBER_ROOM_ID = 2147483647;
|
||||
var PLATFORM;
|
||||
(function (PLATFORM) {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
PLATFORM["MAC"] = "mac";
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
PLATFORM["WIN"] = "win";
|
||||
})(PLATFORM = exports.PLATFORM || (exports.PLATFORM = {}));
|
||||
Generated
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
export declare enum LOG_LEVEL {
|
||||
NORMAL = 0,
|
||||
RELEASE = 1,
|
||||
WARNING = 2,
|
||||
ERROR = 3,
|
||||
NONE = 4
|
||||
}
|
||||
Generated
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.LOG_LEVEL = void 0;
|
||||
/* eslint-disable */
|
||||
// 唯一一个变量格式有问题的, 但是为了和原来 TUICallKit 对外暴露的保持一致
|
||||
var LOG_LEVEL;
|
||||
(function (LOG_LEVEL) {
|
||||
LOG_LEVEL[LOG_LEVEL["NORMAL"] = 0] = "NORMAL";
|
||||
LOG_LEVEL[LOG_LEVEL["RELEASE"] = 1] = "RELEASE";
|
||||
LOG_LEVEL[LOG_LEVEL["WARNING"] = 2] = "WARNING";
|
||||
LOG_LEVEL[LOG_LEVEL["ERROR"] = 3] = "ERROR";
|
||||
LOG_LEVEL[LOG_LEVEL["NONE"] = 4] = "NONE";
|
||||
})(LOG_LEVEL = exports.LOG_LEVEL || (exports.LOG_LEVEL = {}));
|
||||
Generated
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
import TUICallService, { TUIGlobal, TUIStore } from './CallService/index';
|
||||
import { StoreName, NAME, CallRole, CallMediaType, CallStatus, StatusChange, VideoResolution, VideoDisplayMode, AudioPlayBackDevice } from './const/index';
|
||||
import { t } from './locales/index';
|
||||
declare const TUICallKitServer: TUICallService;
|
||||
export { TUIGlobal, TUIStore, StoreName, TUICallKitServer, NAME, CallStatus, CallRole, CallMediaType, StatusChange, VideoResolution, VideoDisplayMode, AudioPlayBackDevice, t, };
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.t = exports.AudioPlayBackDevice = exports.VideoDisplayMode = exports.VideoResolution = exports.StatusChange = exports.CallMediaType = exports.CallRole = exports.CallStatus = exports.NAME = exports.TUICallKitServer = exports.StoreName = exports.TUIStore = exports.TUIGlobal = void 0;
|
||||
const index_1 = __importStar(require("./CallService/index"));
|
||||
Object.defineProperty(exports, "TUIGlobal", { enumerable: true, get: function () { return index_1.TUIGlobal; } });
|
||||
Object.defineProperty(exports, "TUIStore", { enumerable: true, get: function () { return index_1.TUIStore; } });
|
||||
const index_2 = require("./const/index");
|
||||
Object.defineProperty(exports, "StoreName", { enumerable: true, get: function () { return index_2.StoreName; } });
|
||||
Object.defineProperty(exports, "NAME", { enumerable: true, get: function () { return index_2.NAME; } });
|
||||
Object.defineProperty(exports, "CallRole", { enumerable: true, get: function () { return index_2.CallRole; } });
|
||||
Object.defineProperty(exports, "CallMediaType", { enumerable: true, get: function () { return index_2.CallMediaType; } });
|
||||
Object.defineProperty(exports, "CallStatus", { enumerable: true, get: function () { return index_2.CallStatus; } });
|
||||
Object.defineProperty(exports, "StatusChange", { enumerable: true, get: function () { return index_2.StatusChange; } });
|
||||
Object.defineProperty(exports, "VideoResolution", { enumerable: true, get: function () { return index_2.VideoResolution; } });
|
||||
Object.defineProperty(exports, "VideoDisplayMode", { enumerable: true, get: function () { return index_2.VideoDisplayMode; } });
|
||||
Object.defineProperty(exports, "AudioPlayBackDevice", { enumerable: true, get: function () { return index_2.AudioPlayBackDevice; } });
|
||||
const index_3 = require("./locales/index");
|
||||
Object.defineProperty(exports, "t", { enumerable: true, get: function () { return index_3.t; } });
|
||||
// 实例化
|
||||
const TUICallKitServer = index_1.default.getInstance();
|
||||
exports.TUICallKitServer = TUICallKitServer;
|
||||
Generated
Vendored
+93
@@ -0,0 +1,93 @@
|
||||
import { CallStatus, CallRole } from '../const/index';
|
||||
/**
|
||||
* @interface ITUICallService
|
||||
*/
|
||||
export interface ITUICallService {
|
||||
/**
|
||||
* 初始化 Service
|
||||
* @function
|
||||
* @private
|
||||
*/
|
||||
init(params: any): void;
|
||||
/**
|
||||
* 1v1 通话
|
||||
* @function
|
||||
* @param {SwitchUserStatusParams} options 用户状态控制参数
|
||||
*/
|
||||
call(callParams: ICallParams): void;
|
||||
}
|
||||
type SDKAppID = {
|
||||
SDKAppID: number;
|
||||
} | {
|
||||
sdkAppID: number;
|
||||
};
|
||||
export interface IInitParamsBase {
|
||||
userID: string;
|
||||
userSig: string;
|
||||
tim?: any;
|
||||
isFromChat?: boolean;
|
||||
}
|
||||
export type IInitParams = IInitParamsBase & SDKAppID;
|
||||
export interface ICallParams {
|
||||
userID: string;
|
||||
type: number;
|
||||
roomID?: number;
|
||||
userData?: string;
|
||||
timeout?: number;
|
||||
offlinePushInfo?: IOfflinePushInfo;
|
||||
}
|
||||
export interface IGroupCallParams {
|
||||
userIDList: Array<string>;
|
||||
type: number;
|
||||
groupID: string;
|
||||
roomID?: number;
|
||||
userData?: string;
|
||||
timeout?: number;
|
||||
offlinePushInfo?: IOfflinePushInfo;
|
||||
}
|
||||
export interface IUserInfo {
|
||||
userId: string;
|
||||
nick?: string;
|
||||
avatar?: string;
|
||||
remark?: string;
|
||||
displayUserInfo?: string;
|
||||
isAudioAvailable?: boolean;
|
||||
isVideoAvailable?: boolean;
|
||||
volume?: number;
|
||||
isEnter?: boolean;
|
||||
domId?: string;
|
||||
}
|
||||
export interface IOfflinePushInfo {
|
||||
title?: string;
|
||||
description?: string;
|
||||
androidOPPOChannelID?: string;
|
||||
extension: String;
|
||||
}
|
||||
export interface ICallbackParam {
|
||||
beforeCalling?: (...args: any[]) => void;
|
||||
afterCalling?: (...args: any[]) => void;
|
||||
onMinimized?: (...args: any[]) => void;
|
||||
onMessageSentByMe?: (...args: any[]) => void;
|
||||
kickedOut?: (...args: any[]) => void;
|
||||
statusChanged?: (...args: any[]) => void;
|
||||
}
|
||||
export interface ISelfInfoParams {
|
||||
nickName: string;
|
||||
avatar: string;
|
||||
}
|
||||
export interface IBellParams {
|
||||
callRole?: CallRole;
|
||||
callStatus?: CallStatus;
|
||||
isMuteBell?: boolean;
|
||||
calleeBellFilePath?: string;
|
||||
}
|
||||
export interface IInviteUserParams {
|
||||
userIDList: string[];
|
||||
offlinePushInfo?: IOfflinePushInfo;
|
||||
}
|
||||
export interface IJoinInGroupCallParams {
|
||||
type: number;
|
||||
groupID: string;
|
||||
roomID: number;
|
||||
}
|
||||
export {};
|
||||
Generated
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
Generated
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
import { CallStatus, CallRole, CallMediaType, VideoDisplayMode, VideoResolution, TDeviceList } from '../const/index';
|
||||
import { IUserInfo } from './index';
|
||||
export interface IToastInfo {
|
||||
text: string;
|
||||
type?: string;
|
||||
}
|
||||
export interface ICallStore {
|
||||
callStatus: CallStatus;
|
||||
callRole: CallRole;
|
||||
callMediaType: CallMediaType;
|
||||
localUserInfo: IUserInfo;
|
||||
remoteUserInfoList: Array<IUserInfo>;
|
||||
callerUserInfo: IUserInfo;
|
||||
isGroup: boolean;
|
||||
callDuration: string;
|
||||
callTips: string;
|
||||
toastInfo: IToastInfo;
|
||||
isMinimized: boolean;
|
||||
enableFloatWindow: boolean;
|
||||
bigScreenUserId: string;
|
||||
language: string;
|
||||
isClickable: boolean;
|
||||
showPermissionTip: boolean;
|
||||
deviceList: TDeviceList;
|
||||
groupID: string;
|
||||
roomID: number;
|
||||
displayMode: VideoDisplayMode;
|
||||
videoResolution: VideoResolution;
|
||||
pusher: any;
|
||||
player: any[];
|
||||
isEarPhone: boolean;
|
||||
showSelectUser: boolean;
|
||||
}
|
||||
Generated
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
Generated
Vendored
+36
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* @interface TUIGlobal
|
||||
* @property {Object} global 根据运行环境代理 wx、uni、window
|
||||
* @property {Boolean} isPC true 标识是 pc 网页
|
||||
* @property {Boolean} isH5 true 标识是 手机 H5
|
||||
* @property {Boolean} isWeChat true 标识是 微信小程序
|
||||
* @property {Boolean} isApp true 标识是 uniapp 打包的 native app
|
||||
* @property {Boolean} isUniPlatform true 标识当前应用是通过 uniapp 平台打包的产物
|
||||
* @property {Boolean} isOfficial true 标识是腾讯云官网 Demo 应用
|
||||
* @property {Boolean} isWIN true 标识是window系统pc
|
||||
* @property {Boolean} isMAC true 标识是mac os系统pc
|
||||
*/
|
||||
export interface ITUIGlobal {
|
||||
global: any;
|
||||
isPC: boolean;
|
||||
isH5: boolean;
|
||||
isWeChat: boolean;
|
||||
isApp: boolean;
|
||||
isUniPlatform: boolean;
|
||||
isOfficial: boolean;
|
||||
isWIN: boolean;
|
||||
isMAC: boolean;
|
||||
/**
|
||||
* 初始化 TUIGlobal 环境变量
|
||||
* @function
|
||||
* @private
|
||||
*/
|
||||
initEnv(): void;
|
||||
/**
|
||||
* 初始化 isOfficial
|
||||
* @function
|
||||
* @param {number} SDKAppID 当前实例的应用 SDKAppID
|
||||
* @private
|
||||
*/
|
||||
initOfficial(SDKAppID: number): void;
|
||||
}
|
||||
Generated
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
Generated
Vendored
+75
@@ -0,0 +1,75 @@
|
||||
import { StoreName } from '../const/index';
|
||||
export type Task = Record<StoreName, Record<string, Map<(data?: unknown) => void, 1>>>;
|
||||
export interface IOptions {
|
||||
[key: string]: (newData?: any) => void;
|
||||
}
|
||||
/**
|
||||
* @class TUIStore
|
||||
* @property {ICustomStore} customStore 自定义 store,可根据业务需要通过以下 API 进行数据操作。
|
||||
*/
|
||||
export interface ITUIStore {
|
||||
task: Task;
|
||||
/**
|
||||
* UI 组件注册监听
|
||||
* @function
|
||||
* @param {StoreName} storeName store 名称
|
||||
* @param {IOptions} options UI 组件注册的监听信息
|
||||
* @param {Object} params 扩展参数
|
||||
* @param {String} params.notifyRangeWhenWatch 注册时监听时的通知范围
|
||||
* @example
|
||||
* // UI 层监听会话列表更新通知
|
||||
* let onConversationListUpdated = function(conversationList) {
|
||||
* console.warn(conversationList);
|
||||
* }
|
||||
* TUIStore.watch(StoreName.CONV, {
|
||||
* conversationList: onConversationListUpdated,
|
||||
* })
|
||||
*/
|
||||
watch(storeName: StoreName, options: IOptions, params?: any): void;
|
||||
/**
|
||||
* UI 组件取消监听回调
|
||||
* @function
|
||||
* @param {StoreName} storeName store 名称
|
||||
* @param {IOptions} options 监听信息,包含需要取消的回调等
|
||||
* @example
|
||||
* // UI 层取消监听会话列表更新通知
|
||||
* TUIStore.unwatch(StoreName.CONV, {
|
||||
* conversationList: onConversationListUpdated,
|
||||
* })
|
||||
*/
|
||||
unwatch(storeName: StoreName, options: IOptions | string): void;
|
||||
/**
|
||||
* 获取 store 中的数据
|
||||
* @function
|
||||
* @param {StoreName} storeName store 名称
|
||||
* @param {String} key 需要获取的 key
|
||||
* @private
|
||||
*/
|
||||
getData(storeName: StoreName, key: string): any;
|
||||
/**
|
||||
* 更新 store
|
||||
* - 需要使用自定义 store 时可以用此 API 更新自定义数据
|
||||
* @function
|
||||
* @param {StoreName} storeName store 名称
|
||||
* @param {String} key 需要更新的 key
|
||||
* @example
|
||||
* // UI 层更新自定义 Store 数据
|
||||
* TUIStore.update(StoreName.CUSTOM, 'customKey', 'customData')
|
||||
*/
|
||||
update(storeName: StoreName, key: string, data: unknown): void;
|
||||
/**
|
||||
* 重置 store 内数据
|
||||
* @function
|
||||
* @param {StoreName} storeName store 名称
|
||||
* @param {Array<string>} keyList 需要 reset 的 keyList
|
||||
* @param {boolean} isNotificationNeeded 是否需要触发更新
|
||||
* @private
|
||||
*/
|
||||
reset: (storeName: StoreName, keyList?: Array<string>, isNotificationNeeded?: boolean) => void;
|
||||
/**
|
||||
* 修改多个 key-value
|
||||
* @param {Object} params 多个 key-value 组成的 object
|
||||
* @param {StoreName} storeName store 名称
|
||||
*/
|
||||
updateStore: (params: any, name?: StoreName) => void;
|
||||
}
|
||||
Generated
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
Generated
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
export * from './ICallService';
|
||||
export * from './ICallStore';
|
||||
export * from './ITUIGlobal';
|
||||
export * from './ITUIStore';
|
||||
Generated
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__exportStar(require("./ICallService"), exports);
|
||||
__exportStar(require("./ICallStore"), exports);
|
||||
__exportStar(require("./ITUIGlobal"), exports);
|
||||
__exportStar(require("./ITUIStore"), exports);
|
||||
Generated
Vendored
+90
@@ -0,0 +1,90 @@
|
||||
export declare const en: {
|
||||
hangup: string;
|
||||
reject: string;
|
||||
'other side reject call': string;
|
||||
'reject call': string;
|
||||
accept: string;
|
||||
cancel: string;
|
||||
'other side line busy': string;
|
||||
'in busy': string;
|
||||
'call timeout': string;
|
||||
'no response from the other side': string;
|
||||
'end call': string;
|
||||
timeout: string;
|
||||
'kick out': string;
|
||||
'caller calling message': string;
|
||||
'callee calling video message': string;
|
||||
'callee calling audio message': string;
|
||||
'no microphone access': string;
|
||||
'no camera access': string;
|
||||
'invite member': string;
|
||||
speaker: string;
|
||||
'Invited group call': string;
|
||||
'Those involved': string;
|
||||
call: string;
|
||||
'video-call': string;
|
||||
'audio-call': string;
|
||||
search: string;
|
||||
'search-result': string;
|
||||
'no-user': string;
|
||||
'member-not-added': string;
|
||||
'input-phone-userID': string;
|
||||
'not-login': string;
|
||||
'login-status-expire': string;
|
||||
'experience-multi-call': string;
|
||||
'not-support-multi-call': string;
|
||||
userID: string;
|
||||
'already-enter': string;
|
||||
waiting: string;
|
||||
'camera-opened': string;
|
||||
'camera-closed': string;
|
||||
'microphone-opened': string;
|
||||
'microphone-closed': string;
|
||||
camera: string;
|
||||
microphone: string;
|
||||
'image-resolution': string;
|
||||
'default-image-resolution': string;
|
||||
'invited-person': string;
|
||||
'video-to-audio': string;
|
||||
me: string;
|
||||
'be-rejected': string;
|
||||
'be-no-response': string;
|
||||
'be-line-busy': string;
|
||||
'be-canceled': string;
|
||||
'voice-call-end': string;
|
||||
'video-call-end': string;
|
||||
'method-call-failed': string;
|
||||
'failed-to-obtain-permission': string;
|
||||
'environment-detection-failed': string;
|
||||
'switchToAudioCall-call-failed': string;
|
||||
'switchToVideoCall-call-failed': string;
|
||||
'microphone-unavailable': string;
|
||||
'camera-unavailable': string;
|
||||
'ban-device': string;
|
||||
'not-supported-webrtc': string;
|
||||
'blacklist-user-tips': string;
|
||||
'is-already-calling': string;
|
||||
'need-init': string;
|
||||
"can't call yourself": string;
|
||||
'Use-phone-and-computer': string;
|
||||
'Wechat scan right QR code': string;
|
||||
'Scan the QR code above': string;
|
||||
'accept-error': string;
|
||||
'accept-device-error': string;
|
||||
'call-error': string;
|
||||
'browser-authorization': string;
|
||||
'mac-privacy': string;
|
||||
'win-privacy': string;
|
||||
'mac-preferences': string;
|
||||
'win-preferences': string;
|
||||
'open camera': string;
|
||||
'close camera': string;
|
||||
'open microphone': string;
|
||||
'close microphone': string;
|
||||
'Please enter userID': string;
|
||||
'View more': string;
|
||||
'people selected': string;
|
||||
'Select all': string;
|
||||
Cancel: string;
|
||||
Done: string;
|
||||
};
|
||||
Generated
Vendored
+93
@@ -0,0 +1,93 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.en = void 0;
|
||||
exports.en = {
|
||||
'hangup': 'Hang up',
|
||||
'reject': 'Decline',
|
||||
'other side reject call': 'other side reject call',
|
||||
'reject call': 'Reject Call',
|
||||
'accept': 'Accept',
|
||||
'cancel': 'Cancel Call',
|
||||
'other side line busy': 'other side line busy',
|
||||
'in busy': 'in busy',
|
||||
'call timeout': 'call timeout',
|
||||
'no response from the other side': 'no response from the other side',
|
||||
'end call': 'end call',
|
||||
'timeout': 'timeout',
|
||||
'kick out': 'kick out',
|
||||
'caller calling message': 'Waiting for the callee to accept the invitation...',
|
||||
'callee calling video message': 'You are invited to a video call...',
|
||||
'callee calling audio message': 'You are invited to a audio call...',
|
||||
'no microphone access': 'no microphone access',
|
||||
'no camera access': 'no camera access',
|
||||
'invite member': 'Invite Member',
|
||||
'speaker': 'speaker',
|
||||
'Invited group call': 'Invited you to a group call',
|
||||
'Those involved': 'Those involved in the call are',
|
||||
'call': 'call',
|
||||
'video-call': 'video call',
|
||||
'audio-call': 'audio call',
|
||||
'search': 'search',
|
||||
'search-result': 'search result',
|
||||
'no-user': 'user not found',
|
||||
'member-not-added': 'member not added',
|
||||
'input-phone-userID': 'phone number or userID',
|
||||
'not-login': 'not logged in',
|
||||
'login-status-expire': 'login status is invalid, please refresh the page and try again',
|
||||
'experience-multi-call': 'experience multi-person calls, please download the full-featured demo: ',
|
||||
'not-support-multi-call': 'multi-person call interface is not open',
|
||||
'userID': 'userID',
|
||||
'already-enter': 'entered the call',
|
||||
'waiting': 'Calling...',
|
||||
'camera-opened': 'Camera on',
|
||||
'camera-closed': 'Camera off',
|
||||
'microphone-opened': 'Mic on',
|
||||
'microphone-closed': 'Mic off',
|
||||
'camera': 'Camera',
|
||||
'microphone': 'Microphone',
|
||||
'image-resolution': 'Resolution',
|
||||
'default-image-resolution': 'Default',
|
||||
'invited-person': 'Invite',
|
||||
'video-to-audio': 'Switch to audio',
|
||||
'me': '(me)',
|
||||
'be-rejected': 'Call declined, ',
|
||||
'be-no-response': 'No response, ',
|
||||
'be-line-busy': 'Line busy, ',
|
||||
'be-canceled': 'The call is canceled, ',
|
||||
'voice-call-end': 'Voice call ended',
|
||||
'video-call-end': 'Video call ended',
|
||||
'method-call-failed': 'Failed to sync the operation',
|
||||
'failed-to-obtain-permission': 'Failed to obtain permissions',
|
||||
'environment-detection-failed': 'Failed to check the environment',
|
||||
'switchToAudioCall-call-failed': 'switch to audio call method failed',
|
||||
'switchToVideoCall-call-failed': 'switch to video call method failed',
|
||||
'microphone-unavailable': 'No mic found',
|
||||
'camera-unavailable': 'No camera found',
|
||||
'ban-device': 'Device access denied',
|
||||
'not-supported-webrtc': 'Your current environment does not support WebRTC',
|
||||
'blacklist-user-tips': 'The identifier is in blacklist. Failed to send this message!',
|
||||
'is-already-calling': 'TUICallKit is already on a call',
|
||||
'need-init': 'Before initiating a call with TUICallKit, ensure that the TUICallKitServer.init() method has executed successfully. ',
|
||||
"can't call yourself": "Can't call yourself",
|
||||
'Use-phone-and-computer': 'Use your mobile phone and computer to experience video calls',
|
||||
'Wechat scan right QR code': 'Wechat scan right QR code',
|
||||
'Scan the QR code above': 'Scan the QR code above',
|
||||
'accept-error': 'Accept failed',
|
||||
'accept-device-error': 'Accept failed, unable to auth calling device',
|
||||
'call-error': 'Start call failed',
|
||||
'browser-authorization': 'Browser authorization',
|
||||
'mac-privacy': 'System Preferences -> Security and Privacy -> Privacy',
|
||||
'win-privacy': 'Setting -> Privacy and Security -> App permissions',
|
||||
'mac-preferences': 'Open System Preferences',
|
||||
'win-preferences': 'Open Setting',
|
||||
'open camera': 'Open Camera',
|
||||
'close camera': 'Close Camera',
|
||||
'open microphone': 'Open Microphone',
|
||||
'close microphone': 'Close Microphone',
|
||||
'Please enter userID': 'Please enter userID',
|
||||
'View more': 'View more',
|
||||
'people selected': 'people selected',
|
||||
'Select all': 'Select all',
|
||||
'Cancel': 'Cancel',
|
||||
'Done': 'Done',
|
||||
};
|
||||
Generated
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
export declare const CallTips: any;
|
||||
export declare const languageData: languageDataType;
|
||||
export declare function t(key: any): string;
|
||||
interface languageItemType {
|
||||
[key: string]: string;
|
||||
}
|
||||
interface languageDataType {
|
||||
[key: string]: languageItemType;
|
||||
}
|
||||
export {};
|
||||
Generated
Vendored
+51
@@ -0,0 +1,51 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.t = exports.languageData = exports.CallTips = void 0;
|
||||
const index_1 = require("../CallService/index");
|
||||
const index_2 = require("../const/index");
|
||||
const en_1 = require("./en");
|
||||
const zh_cn_1 = require("./zh-cn");
|
||||
const ja_JP_1 = require("./ja_JP");
|
||||
exports.CallTips = {
|
||||
OTHER_SIDE: 'other side',
|
||||
CANCEL: 'cancel',
|
||||
OTHER_SIDE_REJECT_CALL: 'other side reject call',
|
||||
REJECT_CALL: 'reject call',
|
||||
OTHER_SIDE_LINE_BUSY: 'other side line busy',
|
||||
IN_BUSY: 'in busy',
|
||||
CALL_TIMEOUT: 'call timeout',
|
||||
END_CALL: 'end call',
|
||||
TIMEOUT: 'timeout',
|
||||
KICK_OUT: 'kick out',
|
||||
CALLER_CALLING_MSG: 'caller calling message',
|
||||
CALLEE_CALLING_VIDEO_MSG: 'callee calling video message',
|
||||
CALLEE_CALLING_AUDIO_MSG: 'callee calling audio message',
|
||||
NO_MICROPHONE_DEVICE_PERMISSION: 'no microphone access',
|
||||
NO_CAMERA_DEVICE_PERMISSION: 'no camera access',
|
||||
};
|
||||
exports.languageData = {
|
||||
en: en_1.en,
|
||||
'zh-cn': zh_cn_1.zh,
|
||||
ja_JP: ja_JP_1.ja_JP,
|
||||
};
|
||||
// language translate
|
||||
function t(key) {
|
||||
var _a;
|
||||
const language = index_1.TUIStore.getData(index_2.StoreName.CALL, index_2.NAME.LANGUAGE);
|
||||
// eslint-disable-next-line
|
||||
for (const langKey in exports.languageData) {
|
||||
if (langKey === language) {
|
||||
const currentLanguage = exports.languageData[langKey];
|
||||
// eslint-disable-next-line
|
||||
for (const sentenceKey in currentLanguage) {
|
||||
if (sentenceKey === key) {
|
||||
return currentLanguage[sentenceKey];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const enString = (_a = key['en']) === null || _a === void 0 ? void 0 : _a.key; // eslint-disable-line
|
||||
console.error(`${index_2.NAME.PREFIX}translation is not found: ${key}.`);
|
||||
return enString;
|
||||
}
|
||||
exports.t = t;
|
||||
Generated
Vendored
+85
@@ -0,0 +1,85 @@
|
||||
export declare const ja_JP: {
|
||||
hangup: string;
|
||||
reject: string;
|
||||
'other side reject call': string;
|
||||
'reject call': string;
|
||||
accept: string;
|
||||
cancel: string;
|
||||
'other side line busy': string;
|
||||
'in busy': string;
|
||||
'call timeout': string;
|
||||
'end call': string;
|
||||
timeout: string;
|
||||
'kick out': string;
|
||||
'caller calling message': string;
|
||||
'callee calling video message': string;
|
||||
'callee calling audio message': string;
|
||||
'no microphone access': string;
|
||||
'no camera access': string;
|
||||
'invite member': string;
|
||||
speaker: string;
|
||||
'Invited group call': string;
|
||||
'Those involved': string;
|
||||
call: string;
|
||||
'video-call': string;
|
||||
'audio-call': string;
|
||||
search: string;
|
||||
'search-result': string;
|
||||
'Wechat scan right QR code': string;
|
||||
'Use-phone-and-computer': string;
|
||||
'Scan the QR code above': string;
|
||||
'no-user': string;
|
||||
'member-not-added': string;
|
||||
'not-login': string;
|
||||
'login-status-expire': string;
|
||||
'experience-multi-call': string;
|
||||
'not-support-multi-call': string;
|
||||
'input-phone-userID': string;
|
||||
userID: string;
|
||||
'already-enter': string;
|
||||
waiting: string;
|
||||
'camera-opened': string;
|
||||
'camera-closed': string;
|
||||
'microphone-opened': string;
|
||||
'microphone-closed': string;
|
||||
camera: string;
|
||||
microphone: string;
|
||||
'image-resolution': string;
|
||||
'default-image-resolution': string;
|
||||
'invited-person': string;
|
||||
'video-to-audio': string;
|
||||
me: string;
|
||||
'be-rejected': string;
|
||||
'be-no-response': string;
|
||||
'be-line-busy': string;
|
||||
'be-canceled': string;
|
||||
'voice-call-end': string;
|
||||
'video-call-end': string;
|
||||
'method-call-failed': string;
|
||||
'failed-to-obtain-permission': string;
|
||||
'environment-detection-failed': string;
|
||||
'switchToAudioCall-call-failed': string;
|
||||
'switchToVideoCall-call-failed': string;
|
||||
'microphone-unavailable': string;
|
||||
'camera-unavailable': string;
|
||||
'ban-device': string;
|
||||
'not-supported-webrtc': string;
|
||||
'blacklist-user-tips': string;
|
||||
'is-already-calling': string;
|
||||
'need-init': string;
|
||||
"can't call yourself": string;
|
||||
'accept-error': string;
|
||||
'accept-device-error': string;
|
||||
'call-error': string;
|
||||
'browser-authorization': string;
|
||||
'mac-privacy': string;
|
||||
'win-privacy': string;
|
||||
'mac-preferences': string;
|
||||
'win-preferences': string;
|
||||
'Please enter userID': string;
|
||||
'View more': string;
|
||||
'people selected': string;
|
||||
'Select all': string;
|
||||
Cancel: string;
|
||||
Done: string;
|
||||
};
|
||||
Generated
Vendored
+88
@@ -0,0 +1,88 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ja_JP = void 0;
|
||||
exports.ja_JP = {
|
||||
'hangup': '通話終了',
|
||||
'reject': '拒否',
|
||||
'other side reject call': '通話が拒否されました',
|
||||
'reject call': '通話拒否',
|
||||
'accept': '応答',
|
||||
'cancel': '通話をキャンセル',
|
||||
'other side line busy': '相手が通話中です',
|
||||
'in busy': '通話中',
|
||||
'call timeout': '呼び出しタイムアウト',
|
||||
'end call': '通話終了',
|
||||
'timeout': 'タイムアウト',
|
||||
'kick out': 'キックアウトされました',
|
||||
'caller calling message': '相手が招待を承諾するのを待っています。',
|
||||
'callee calling video message': 'ビデオ通話に招待されました。',
|
||||
'callee calling audio message': '音声通話に招待されました。',
|
||||
'no microphone access': 'マイクにアクセスできません',
|
||||
'no camera access': 'カメラにアクセスできません',
|
||||
'invite member': 'メンバーを招待する',
|
||||
'speaker': 'スピーカー',
|
||||
'Invited group call': 'グループ通話に招待されました。',
|
||||
'Those involved': '参加者:',
|
||||
'call': '通話',
|
||||
'video-call': 'ビデオ通話',
|
||||
'audio-call': '音声通話',
|
||||
'search': '検索',
|
||||
'search-result': '検索結果',
|
||||
'Wechat scan right QR code': 'WeChatで右側にあるQRコードを読み取ります。',
|
||||
'Use-phone-and-computer': '携帯電話とコンピュータを使用してビデオ通話を体験してください',
|
||||
'Scan the QR code above': '上のQRコードを読み取ります。',
|
||||
'no-user': 'ユーザーが見つかりませんでした',
|
||||
'member-not-added': 'メンバーが追加されていません',
|
||||
'not-login': 'ログインしていません',
|
||||
'login-status-expire': 'ログインの有効期限が過ぎています。ページを更新してもう一度お試しください',
|
||||
'experience-multi-call': '複数人で同時に音声通話できるグループ通話機能を体験するには、全機能のデモをダウンロードしてください',
|
||||
'not-support-multi-call': 'グループ通話インターフェイスが開いていません',
|
||||
'input-phone-userID': '携帯電話番号/ユーザーIDを入力してください',
|
||||
'userID': 'ユーザーID',
|
||||
'already-enter': 'すでに通話に参加しています',
|
||||
'waiting': '応答を待っています...',
|
||||
'camera-opened': 'カメラがオンになっています',
|
||||
'camera-closed': 'カメラがオフになっています',
|
||||
'microphone-opened': 'マイクがオンになっています',
|
||||
'microphone-closed': 'マイクがオフになっています',
|
||||
'camera': 'カメラ',
|
||||
'microphone': 'マイク',
|
||||
'image-resolution': '解像度',
|
||||
'default-image-resolution': 'デフォルト解像度',
|
||||
'invited-person': 'メンバーを招待',
|
||||
'video-to-audio': '音声通話に切り替えます',
|
||||
'me': '(自分)',
|
||||
'be-rejected': '通話が拒否されました, ',
|
||||
'be-no-response': '応答なし, ',
|
||||
'be-line-busy': '相手が通話中です, ',
|
||||
'be-canceled': '相手が通話をキャンセルしました',
|
||||
'voice-call-end': '音声通話が終了しました',
|
||||
'video-call-end': 'ビデオ通話が終了しました',
|
||||
'method-call-failed': '操作の同期に失敗しました',
|
||||
'failed-to-obtain-permission': '権限の取得に失敗しました',
|
||||
'environment-detection-failed': '環境の検出に失敗しました',
|
||||
'switchToAudioCall-call-failed': '音声通話に切り替えることはできません',
|
||||
'switchToVideoCall-call-failed': 'ビデオ通話に切り替えることはできません',
|
||||
'microphone-unavailable': '使用できるマイクがありません',
|
||||
'camera-unavailable': '使用できるカメラがありません',
|
||||
'ban-device': 'デバイスへのアクセスが拒否されました',
|
||||
'not-supported-webrtc': '現在の環境はWebRTCをサポートしていません',
|
||||
'blacklist-user-tips': 'ユーザーはブラックリストに登録され、通話が開始できませんでした',
|
||||
'is-already-calling': 'TUICallKit はすでに通話中です',
|
||||
'need-init': 'TUICallKitで通話を開始する前に、TUICallKitServer.init() メソッドが正常に実行されたことを確認してください。',
|
||||
"can't call yourself": '自分に電話をかけることができません',
|
||||
'accept-error': '接続できませんでした',
|
||||
'accept-device-error': '接続できませんでした。発信側デバイスを認証できません',
|
||||
'call-error': '通話が開始できませんでした',
|
||||
'browser-authorization': 'ブラウザ認証',
|
||||
'mac-privacy': 'システム環境設定 -> セキュリティとプライバシー ->プライバシー',
|
||||
'win-privacy': '設定 -> セキュリティとプライバシー ->アプリのアクセス許可',
|
||||
'mac-preferences': 'システム環境設定を開く',
|
||||
'win-preferences': 'システム設定を開く',
|
||||
'Please enter userID': 'ユーザーIDを入力してください',
|
||||
'View more': 'もっと見る',
|
||||
'people selected': '人が選択されました',
|
||||
'Select all': 'すべて選択',
|
||||
'Cancel': 'キャンセル',
|
||||
'Done': '完了',
|
||||
};
|
||||
Generated
Vendored
+89
@@ -0,0 +1,89 @@
|
||||
export declare const zh: {
|
||||
hangup: string;
|
||||
reject: string;
|
||||
'other side reject call': string;
|
||||
'reject call': string;
|
||||
accept: string;
|
||||
cancel: string;
|
||||
'other side line busy': string;
|
||||
'in busy': string;
|
||||
'call timeout': string;
|
||||
'end call': string;
|
||||
timeout: string;
|
||||
'kick out': string;
|
||||
'caller calling message': string;
|
||||
'callee calling video message': string;
|
||||
'callee calling audio message': string;
|
||||
'no microphone access': string;
|
||||
'no camera access': string;
|
||||
'invite member': string;
|
||||
speaker: string;
|
||||
'Invited group call': string;
|
||||
'Those involved': string;
|
||||
call: string;
|
||||
'video-call': string;
|
||||
'audio-call': string;
|
||||
search: string;
|
||||
'search-result': string;
|
||||
'Wechat scan right QR code': string;
|
||||
'Use-phone-and-computer': string;
|
||||
'Scan the QR code above': string;
|
||||
'no-user': string;
|
||||
'member-not-added': string;
|
||||
'not-login': string;
|
||||
'login-status-expire': string;
|
||||
'experience-multi-call': string;
|
||||
'not-support-multi-call': string;
|
||||
'input-phone-userID': string;
|
||||
userID: string;
|
||||
'already-enter': string;
|
||||
waiting: string;
|
||||
'camera-opened': string;
|
||||
'camera-closed': string;
|
||||
'microphone-opened': string;
|
||||
'microphone-closed': string;
|
||||
camera: string;
|
||||
microphone: string;
|
||||
'image-resolution': string;
|
||||
'default-image-resolution': string;
|
||||
'invited-person': string;
|
||||
'video-to-audio': string;
|
||||
me: string;
|
||||
'be-rejected': string;
|
||||
'be-no-response': string;
|
||||
'be-line-busy': string;
|
||||
'be-canceled': string;
|
||||
'voice-call-end': string;
|
||||
'video-call-end': string;
|
||||
'method-call-failed': string;
|
||||
'failed-to-obtain-permission': string;
|
||||
'environment-detection-failed': string;
|
||||
'switchToAudioCall-call-failed': string;
|
||||
'switchToVideoCall-call-failed': string;
|
||||
'microphone-unavailable': string;
|
||||
'camera-unavailable': string;
|
||||
'ban-device': string;
|
||||
'not-supported-webrtc': string;
|
||||
'blacklist-user-tips': string;
|
||||
'is-already-calling': string;
|
||||
'need-init': string;
|
||||
"can't call yourself": string;
|
||||
'accept-error': string;
|
||||
'accept-device-error': string;
|
||||
'call-error': string;
|
||||
'browser-authorization': string;
|
||||
'mac-privacy': string;
|
||||
'win-privacy': string;
|
||||
'mac-preferences': string;
|
||||
'win-preferences': string;
|
||||
'open camera': string;
|
||||
'close camera': string;
|
||||
'open microphone': string;
|
||||
'close microphone': string;
|
||||
'Please enter userID': string;
|
||||
'View more': string;
|
||||
'people selected': string;
|
||||
'Select all': string;
|
||||
Cancel: string;
|
||||
Done: string;
|
||||
};
|
||||
Generated
Vendored
+92
@@ -0,0 +1,92 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.zh = void 0;
|
||||
exports.zh = {
|
||||
'hangup': '挂断',
|
||||
'reject': '拒绝',
|
||||
'other side reject call': '对方已拒绝',
|
||||
'reject call': '拒绝通话',
|
||||
'accept': '接受',
|
||||
'cancel': '取消通话',
|
||||
'other side line busy': '对方忙线',
|
||||
'in busy': '正在忙',
|
||||
'call timeout': '呼叫超时',
|
||||
'end call': '结束通话',
|
||||
'timeout': '超时',
|
||||
'kick out': '被踢',
|
||||
'caller calling message': '正在等待对方接受邀请…',
|
||||
'callee calling video message': '邀请您进行视频通话…',
|
||||
'callee calling audio message': '邀请您进行语音通话…',
|
||||
'no microphone access': '没有麦克风权限',
|
||||
'no camera access': '没有摄像头权限',
|
||||
'invite member': '邀请成员',
|
||||
'speaker': '扬声器',
|
||||
'Invited group call': '邀请你参加多人通话',
|
||||
'Those involved': '参与通话的有:',
|
||||
'call': '通话',
|
||||
'video-call': '视频通话',
|
||||
'audio-call': '音频通话',
|
||||
'search': '搜索',
|
||||
'search-result': '搜索结果',
|
||||
'Wechat scan right QR code': '微信扫右二维码',
|
||||
'Use-phone-and-computer': '用手机与电脑互打体验视频通话',
|
||||
'Scan the QR code above': '扫描上方二维码',
|
||||
'no-user': '未搜索到用户',
|
||||
'member-not-added': '未添加成员',
|
||||
'not-login': '未登录',
|
||||
'login-status-expire': '登录状态已失效,请刷新网页重试',
|
||||
'experience-multi-call': '体验多人通话请下载全功能demo:',
|
||||
'not-support-multi-call': '多人通话接口未开放',
|
||||
'input-phone-userID': '请输入手机号/用户ID',
|
||||
'userID': '用户ID',
|
||||
'already-enter': '已经进入当前通话',
|
||||
'waiting': '等待接听...',
|
||||
'camera-opened': '摄像头已开',
|
||||
'camera-closed': '摄像头已关',
|
||||
'microphone-opened': '麦克风已开',
|
||||
'microphone-closed': '麦克风已关',
|
||||
'camera': '摄像头',
|
||||
'microphone': '麦克风',
|
||||
'image-resolution': '分辨率',
|
||||
'default-image-resolution': '默认分辨率',
|
||||
'invited-person': '添加成员',
|
||||
'video-to-audio': '切到语音通话',
|
||||
'me': '(我)',
|
||||
'be-rejected': '对方已拒绝,',
|
||||
'be-no-response': '对方无应答,',
|
||||
'be-line-busy': '对方忙线中,',
|
||||
'be-canceled': '对方已取消',
|
||||
'voice-call-end': '语音通话结束',
|
||||
'video-call-end': '视频通话结束',
|
||||
'method-call-failed': '同步操作失败',
|
||||
'failed-to-obtain-permission': '权限获取失败',
|
||||
'environment-detection-failed': '环境检测失败',
|
||||
'switchToAudioCall-call-failed': '切语音调用失败',
|
||||
'switchToVideoCall-call-failed': '切视频调用失败',
|
||||
'microphone-unavailable': '没有可用的麦克风设备',
|
||||
'camera-unavailable': '没有可用的摄像头设备',
|
||||
'ban-device': '用户禁止使用设备',
|
||||
'not-supported-webrtc': '当前环境不支持 WebRTC',
|
||||
'blacklist-user-tips': '发起通话失败,被对方拉入黑名单,禁止发起!',
|
||||
'is-already-calling': 'TUICallKit 已在通话状态',
|
||||
'need-init': 'TUICallKit 发起通话前需保证 TUICallKitServer.init() 方法执行成功',
|
||||
"can't call yourself": '不能呼叫自己',
|
||||
'accept-error': '接通失败',
|
||||
'accept-device-error': '接通失败,通话设备获取失败',
|
||||
'call-error': '发起通话失败',
|
||||
'browser-authorization': '浏览器授权',
|
||||
'mac-privacy': '系统偏好设置 -> 安全与隐私 -> 隐私',
|
||||
'win-privacy': '设置 -> 隐私和安全性 -> 应用权限',
|
||||
'mac-preferences': '打开系统偏好设置',
|
||||
'win-preferences': '打开系统设置',
|
||||
'open camera': '打开摄像头',
|
||||
'close camera': '关闭摄像头',
|
||||
'open microphone': '打开麦克风',
|
||||
'close microphone': '关闭麦克风',
|
||||
'Please enter userID': '请输入 userID',
|
||||
'View more': '查看更多',
|
||||
'people selected': '人已选中',
|
||||
'Select all': '全选',
|
||||
'Cancel': '取消',
|
||||
'Done': '完成',
|
||||
};
|
||||
Generated
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
export declare class CallManager {
|
||||
private _globalCallPagePath;
|
||||
private _isPageRedirected;
|
||||
init(params: any): Promise<void>;
|
||||
private _watchTUIStore;
|
||||
private _unwatchTUIStore;
|
||||
private _handleCallStatusChange;
|
||||
private _handleCallStatusToCalling;
|
||||
private _handleCallStatusToIdle;
|
||||
destroyed(): Promise<void>;
|
||||
}
|
||||
Generated
Vendored
+133
@@ -0,0 +1,133 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CallManager = void 0;
|
||||
const index_1 = require("../../index");
|
||||
const index_2 = require("../const/index");
|
||||
const index_3 = require("../utils/validate/index");
|
||||
/**
|
||||
* @param {Number} sdkAppID 用户的sdkAppID 必传
|
||||
* @param {String} userID 用户的userID 必传
|
||||
* @param {String} userSig 用户的userSig 必传
|
||||
* @param {String} globalCallPagePath 跳转的路径 必传
|
||||
* @param {ChatSDK} tim tim实例 非必传
|
||||
*/
|
||||
const PREFIX = 'callManager';
|
||||
class CallManager {
|
||||
constructor() {
|
||||
this._globalCallPagePath = '';
|
||||
this._isPageRedirected = false;
|
||||
this._handleCallStatusChange = (value) => __awaiter(this, void 0, void 0, function* () {
|
||||
switch (value) {
|
||||
case index_2.CallStatus.CALLING:
|
||||
case index_2.CallStatus.CONNECTED:
|
||||
this._handleCallStatusToCalling();
|
||||
break;
|
||||
case index_2.CallStatus.IDLE:
|
||||
this._handleCallStatusToIdle();
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
init(params) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const { sdkAppID, userID, userSig, globalCallPagePath, tim } = params;
|
||||
if (!globalCallPagePath) {
|
||||
console.error(`${PREFIX} globalCallPagePath Can not be empty!`);
|
||||
return;
|
||||
}
|
||||
;
|
||||
this._globalCallPagePath = globalCallPagePath;
|
||||
try {
|
||||
yield index_1.TUICallKitServer.init({
|
||||
sdkAppID,
|
||||
userID,
|
||||
userSig,
|
||||
tim,
|
||||
});
|
||||
this._watchTUIStore();
|
||||
// 全局监听下,关闭悬浮窗
|
||||
index_1.TUICallKitServer.enableFloatWindow(false);
|
||||
console.log(`${PREFIX} init Ready!`);
|
||||
}
|
||||
catch (error) {
|
||||
console.error(`${PREFIX} init fail!`);
|
||||
}
|
||||
});
|
||||
}
|
||||
// =========================【监听 TUIStore 中的状态】=========================
|
||||
_watchTUIStore() {
|
||||
index_1.TUIStore === null || index_1.TUIStore === void 0 ? void 0 : index_1.TUIStore.watch(index_1.StoreName.CALL, {
|
||||
[index_1.NAME.CALL_STATUS]: this._handleCallStatusChange,
|
||||
}, {
|
||||
notifyRangeWhenWatch: index_1.NAME.MYSELF,
|
||||
});
|
||||
}
|
||||
_unwatchTUIStore() {
|
||||
index_1.TUIStore === null || index_1.TUIStore === void 0 ? void 0 : index_1.TUIStore.unwatch(index_1.StoreName.CALL, {
|
||||
[index_1.NAME.CALL_STATUS]: this._handleCallStatusChange,
|
||||
});
|
||||
}
|
||||
_handleCallStatusToCalling() {
|
||||
if (this._isPageRedirected)
|
||||
return;
|
||||
// @ts-ignore
|
||||
wx.navigateTo({
|
||||
url: `/${this._globalCallPagePath}`,
|
||||
success: () => {
|
||||
this._isPageRedirected = true;
|
||||
},
|
||||
fail: () => {
|
||||
console.error(`${PREFIX} navigateTo fail!`);
|
||||
},
|
||||
complete: () => { },
|
||||
});
|
||||
}
|
||||
_handleCallStatusToIdle() {
|
||||
if (!this._isPageRedirected)
|
||||
return;
|
||||
// @ts-ignore
|
||||
wx.navigateBack({
|
||||
success: () => {
|
||||
this._isPageRedirected = false;
|
||||
},
|
||||
fail: () => {
|
||||
console.error(`${PREFIX} navigateBack fail!`);
|
||||
},
|
||||
complete: () => { },
|
||||
});
|
||||
}
|
||||
// 卸载 callManger
|
||||
destroyed() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
this._globalCallPagePath = '';
|
||||
this._isPageRedirected = false;
|
||||
this._unwatchTUIStore();
|
||||
yield index_1.TUICallKitServer.destroyed();
|
||||
});
|
||||
}
|
||||
}
|
||||
__decorate([
|
||||
(0, index_3.avoidRepeatedCall)(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], CallManager.prototype, "init", null);
|
||||
exports.CallManager = CallManager;
|
||||
Generated
Vendored
+53
@@ -0,0 +1,53 @@
|
||||
export declare const isUndefined: (input: any) => boolean;
|
||||
export declare const isPlainObject: (input: any) => boolean;
|
||||
export declare const isArray: (input: any) => boolean;
|
||||
export declare const isPrivateKey: (key: string) => boolean;
|
||||
export declare const isUrl: (url: string) => boolean;
|
||||
/**
|
||||
* 检测input类型是否为string
|
||||
* @param {*} input 任意类型的输入
|
||||
* @returns {Boolean} true->string / false->not a string
|
||||
*/
|
||||
export declare const isString: (input: any) => boolean;
|
||||
export declare const isBoolean: (input: any) => boolean;
|
||||
export declare const isNumber: (input: any) => boolean;
|
||||
export declare function formatTime(secondTime: number): string;
|
||||
export declare function formatTimeInverse(stringTime: string): number;
|
||||
export declare function isJSON(str: string): boolean;
|
||||
export declare const JSONToObject: (str: string) => any;
|
||||
/**
|
||||
* 重试函数, catch 时,重试
|
||||
* @param {Promise} promise 需重试的函数
|
||||
* @param {number} num 需要重试的次数
|
||||
* @param {number} time 间隔时间(s)
|
||||
* @returns {Promise<any>} im 接口的 response 原样返回
|
||||
*/
|
||||
export declare const retryPromise: (promise: Promise<any>, num?: number, time?: number) => Promise<any>;
|
||||
/**
|
||||
* web call engine 重复调用时的错误, 这种错误在 TUICallKit 应该忽略
|
||||
* @param {any} error 错误信息
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
export declare function handleRepeatedCallError(error: any): boolean;
|
||||
/**
|
||||
* 设备无权限时的错误处理
|
||||
* @param {any} error 错误信息
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
export declare function handleNoDevicePermissionError(error: any): boolean;
|
||||
export declare function performanceNow(): number;
|
||||
/**
|
||||
* 检测input类型是否为function
|
||||
* @param {*} input 任意类型的输入
|
||||
* @returns {Boolean} true->input is a function
|
||||
*/
|
||||
export declare const isFunction: (input: any) => boolean;
|
||||
export declare const getLanguage: () => string;
|
||||
export declare function noop(e: any): void;
|
||||
/**
|
||||
* Get the object type string
|
||||
* @param {*} input 任意类型的输入
|
||||
* @returns {String} the object type string
|
||||
*/
|
||||
export declare const getType: (input: any) => any;
|
||||
export declare function modifyObjectKey(obj: any, oldKey: any, newKey: any): any;
|
||||
Generated
Vendored
+249
@@ -0,0 +1,249 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.modifyObjectKey = exports.getType = exports.noop = exports.getLanguage = exports.isFunction = exports.performanceNow = exports.handleNoDevicePermissionError = exports.handleRepeatedCallError = exports.retryPromise = exports.JSONToObject = exports.isJSON = exports.formatTimeInverse = exports.formatTime = exports.isNumber = exports.isBoolean = exports.isString = exports.isUrl = exports.isPrivateKey = exports.isArray = exports.isPlainObject = exports.isUndefined = void 0;
|
||||
const index_1 = require("../const/index");
|
||||
const tuiGlobal_1 = __importDefault(require("../TUIGlobal/tuiGlobal"));
|
||||
const isUndefined = function (input) {
|
||||
return typeof input === index_1.NAME.UNDEFINED;
|
||||
};
|
||||
exports.isUndefined = isUndefined;
|
||||
const isPlainObject = function (input) {
|
||||
// 注意不能使用以下方式判断,因为IE9/IE10下,对象的__proto__是 undefined
|
||||
// return isObject(input) && input.__proto__ === Object.prototype;
|
||||
if (typeof input !== index_1.NAME.OBJECT || input === null) {
|
||||
return false;
|
||||
}
|
||||
const proto = Object.getPrototypeOf(input);
|
||||
if (proto === null) { // edge case Object.create(null)
|
||||
return true;
|
||||
}
|
||||
let baseProto = proto;
|
||||
while (Object.getPrototypeOf(baseProto) !== null) {
|
||||
baseProto = Object.getPrototypeOf(baseProto);
|
||||
}
|
||||
// 原型链第一个和最后一个比较
|
||||
return proto === baseProto;
|
||||
};
|
||||
exports.isPlainObject = isPlainObject;
|
||||
const isArray = function (input) {
|
||||
if (typeof Array.isArray === index_1.NAME.FUNCTION) {
|
||||
return Array.isArray(input);
|
||||
}
|
||||
return Object.prototype.toString.call(input).match(/^\[object (.*)\]$/)[1].toLowerCase() === index_1.NAME.ARRAY;
|
||||
};
|
||||
exports.isArray = isArray;
|
||||
const isPrivateKey = function (key) {
|
||||
return key.startsWith('_');
|
||||
};
|
||||
exports.isPrivateKey = isPrivateKey;
|
||||
const isUrl = function (url) {
|
||||
return /^(https?:\/\/(([a-zA-Z0-9]+-?)+[a-zA-Z0-9]+\.)+[a-zA-Z]+)(:\d+)?(\/.*)?(\?.*)?(#.*)?$/.test(url);
|
||||
};
|
||||
exports.isUrl = isUrl;
|
||||
/**
|
||||
* 检测input类型是否为string
|
||||
* @param {*} input 任意类型的输入
|
||||
* @returns {Boolean} true->string / false->not a string
|
||||
*/
|
||||
const isString = function (input) {
|
||||
return typeof input === index_1.NAME.STRING;
|
||||
};
|
||||
exports.isString = isString;
|
||||
const isBoolean = function (input) {
|
||||
return typeof input === index_1.NAME.BOOLEAN;
|
||||
};
|
||||
exports.isBoolean = isBoolean;
|
||||
const isNumber = function (input) {
|
||||
return (
|
||||
// eslint-disable-next-line
|
||||
input !== null &&
|
||||
((typeof input === index_1.NAME.NUMBER && !isNaN(input - 0)) || (typeof input === index_1.NAME.OBJECT && input.constructor === Number)));
|
||||
};
|
||||
exports.isNumber = isNumber;
|
||||
function formatTime(secondTime) {
|
||||
const hours = Math.floor(secondTime / 3600);
|
||||
const minutes = Math.floor((secondTime % 3600) / 60);
|
||||
const seconds = Math.floor(secondTime % 60);
|
||||
let callDurationStr = hours > 9 ? `${hours}` : `0${hours}`;
|
||||
callDurationStr += minutes > 9 ? `:${minutes}` : `:0${minutes}`;
|
||||
callDurationStr += seconds > 9 ? `:${seconds}` : `:0${seconds}`;
|
||||
return callDurationStr;
|
||||
}
|
||||
exports.formatTime = formatTime;
|
||||
function formatTimeInverse(stringTime) {
|
||||
const list = stringTime.split(':');
|
||||
return parseInt(list[0]) * 3600 + parseInt(list[1]) * 60 + parseInt(list[2]); // eslint-disable-line
|
||||
}
|
||||
exports.formatTimeInverse = formatTimeInverse;
|
||||
// Determine if it is a JSON string
|
||||
function isJSON(str) {
|
||||
if (typeof str === index_1.NAME.STRING) {
|
||||
try {
|
||||
const data = JSON.parse(str);
|
||||
if (data) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
catch (error) {
|
||||
console.debug(error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
exports.isJSON = isJSON;
|
||||
// Determine if it is a JSON string
|
||||
const JSONToObject = function (str) {
|
||||
if (!str || !isJSON(str)) {
|
||||
return str;
|
||||
}
|
||||
return JSON.parse(str);
|
||||
};
|
||||
exports.JSONToObject = JSONToObject;
|
||||
/**
|
||||
* 重试函数, catch 时,重试
|
||||
* @param {Promise} promise 需重试的函数
|
||||
* @param {number} num 需要重试的次数
|
||||
* @param {number} time 间隔时间(s)
|
||||
* @returns {Promise<any>} im 接口的 response 原样返回
|
||||
*/
|
||||
const retryPromise = (promise, num = 6, time = 0.5) => {
|
||||
let n = num;
|
||||
const func = () => promise;
|
||||
return func()
|
||||
.catch((error) => {
|
||||
if (n === 0) {
|
||||
throw error;
|
||||
}
|
||||
const timer = setTimeout(() => {
|
||||
func();
|
||||
clearTimeout(timer);
|
||||
n = n - 1;
|
||||
}, time * 1000);
|
||||
});
|
||||
};
|
||||
exports.retryPromise = retryPromise;
|
||||
// /**
|
||||
// * 节流函数(目前 TUICallKit 增加防重调用装饰器,该方法可删除)
|
||||
// * @param {Function} func 传入的函数
|
||||
// * @param {wait} time 间隔时间(ms)
|
||||
// */
|
||||
// export const throttle = (func: Function, wait: number) => {
|
||||
// let previousTime = 0;
|
||||
// return function () {
|
||||
// const now = Date.now();
|
||||
// const args = [...arguments];
|
||||
// if (now - previousTime > wait) {
|
||||
// func.apply(this, args);
|
||||
// previousTime = now;
|
||||
// }
|
||||
// };
|
||||
// }
|
||||
/**
|
||||
* web call engine 重复调用时的错误, 这种错误在 TUICallKit 应该忽略
|
||||
* @param {any} error 错误信息
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
function handleRepeatedCallError(error) {
|
||||
if ((error === null || error === void 0 ? void 0 : error.message.indexOf('is ongoing, please avoid repeated calls')) !== -1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
exports.handleRepeatedCallError = handleRepeatedCallError;
|
||||
/**
|
||||
* 设备无权限时的错误处理
|
||||
* @param {any} error 错误信息
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
function handleNoDevicePermissionError(error) {
|
||||
const { message } = error;
|
||||
if (message.indexOf('NotAllowedError: Permission denied') !== -1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
exports.handleNoDevicePermissionError = handleNoDevicePermissionError;
|
||||
/*
|
||||
* 获取向下取整的 performance.now() 值
|
||||
* @export
|
||||
* @return {Number}
|
||||
*/
|
||||
function performanceNow() {
|
||||
// 在不支持 performance.now 的浏览器中,使用 Date.now()
|
||||
// 例如 ie 9,ie 10,避免加载 sdk 时报错
|
||||
if (!performance || !performance.now) {
|
||||
return Date.now();
|
||||
}
|
||||
return Math.floor(performance.now());
|
||||
}
|
||||
exports.performanceNow = performanceNow;
|
||||
/**
|
||||
* 检测input类型是否为function
|
||||
* @param {*} input 任意类型的输入
|
||||
* @returns {Boolean} true->input is a function
|
||||
*/
|
||||
const isFunction = function (input) {
|
||||
return typeof input === index_1.NAME.FUNCTION;
|
||||
};
|
||||
exports.isFunction = isFunction;
|
||||
/*
|
||||
* 获取浏览器语言
|
||||
* @export
|
||||
* @return {zh-cn | en}
|
||||
*/
|
||||
const getLanguage = () => {
|
||||
if (tuiGlobal_1.default.getInstance().isWeChat) {
|
||||
return 'zh-cn';
|
||||
}
|
||||
// @ts-ignore
|
||||
const lang = ((navigator === null || navigator === void 0 ? void 0 : navigator.language) || (navigator === null || navigator === void 0 ? void 0 : navigator.userLanguage) || '').substr(0, 2);
|
||||
let language = 'en';
|
||||
switch (lang) {
|
||||
case 'zh':
|
||||
language = 'zh-cn';
|
||||
break;
|
||||
case 'ja':
|
||||
language = 'ja_JP';
|
||||
break;
|
||||
default:
|
||||
language = 'en';
|
||||
}
|
||||
return language;
|
||||
};
|
||||
exports.getLanguage = getLanguage;
|
||||
function noop(e) { }
|
||||
exports.noop = noop;
|
||||
/**
|
||||
* Get the object type string
|
||||
* @param {*} input 任意类型的输入
|
||||
* @returns {String} the object type string
|
||||
*/
|
||||
const getType = function (input) {
|
||||
return Object.prototype.toString
|
||||
.call(input)
|
||||
.match(/^\[object (.*)\]$/)[1]
|
||||
.toLowerCase();
|
||||
};
|
||||
exports.getType = getType;
|
||||
// 修改对象键名
|
||||
function modifyObjectKey(obj, oldKey, newKey) {
|
||||
if (!obj.hasOwnProperty(oldKey)) {
|
||||
return obj;
|
||||
}
|
||||
const newObj = {};
|
||||
Object.keys(obj).forEach(key => {
|
||||
if (key === oldKey) {
|
||||
newObj[newKey] = obj[key];
|
||||
}
|
||||
else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
});
|
||||
return newObj;
|
||||
}
|
||||
exports.modifyObjectKey = modifyObjectKey;
|
||||
Generated
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
export declare const IN_WX_MINI_APP: boolean;
|
||||
export declare const IN_UNI_NATIVE_APP: boolean;
|
||||
export declare const IN_MINI_APP: boolean;
|
||||
export declare const IN_UNI_APP: boolean;
|
||||
export declare const IN_BROWSER: boolean;
|
||||
export declare const APP_NAMESPACE: any;
|
||||
export declare const IS_H5: boolean;
|
||||
export declare const IS_PC: boolean;
|
||||
export declare const IS_WIN: any;
|
||||
export declare const IS_MAC: any;
|
||||
Generated
Vendored
+39
@@ -0,0 +1,39 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.IS_MAC = exports.IS_WIN = exports.IS_PC = exports.IS_H5 = exports.APP_NAMESPACE = exports.IN_BROWSER = exports.IN_UNI_APP = exports.IN_MINI_APP = exports.IN_UNI_NATIVE_APP = exports.IN_WX_MINI_APP = void 0;
|
||||
// 在 uniApp 框架下,打包 H5、ios app、android app 时存在 wx/qq/tt/swan/my 等变量会导致引入 web sdk 环境判断失效
|
||||
// 小程序 getSystemInfoSync 返回的 fontSizeSetting 在 H5 和 app 中为 undefined,所以通过 fontSizeSetting 增强小程序环境判断
|
||||
// wx 小程序
|
||||
exports.IN_WX_MINI_APP = (typeof wx !== 'undefined' && typeof wx.getSystemInfoSync === 'function' && Boolean(wx.getSystemInfoSync().fontSizeSetting));
|
||||
// 用 uni-app 打包 native app,此时运行于 js core,无 window 等对象,此时调用 api 都得 uni.xxx,由于风格跟小程序类似,就归为 IN_MINI_APP 的一种
|
||||
exports.IN_UNI_NATIVE_APP = (typeof uni !== 'undefined' && typeof uni === 'undefined');
|
||||
exports.IN_MINI_APP = exports.IN_WX_MINI_APP || exports.IN_UNI_NATIVE_APP;
|
||||
exports.IN_UNI_APP = (typeof uni !== 'undefined');
|
||||
// 在 uniApp 框架下,由于客户打包 ios app、android app 时 window 不一定存在,所以通过 !IN_MINI_APP 进行判断
|
||||
// 非 uniApp 框架下,仍然通过 window 结合 IN_MINI_APP 进行判断,可兼容 Taro3.0+ 暴露 window 对象引起的 IN_BROWSER 判断失效问题
|
||||
exports.IN_BROWSER = (function () {
|
||||
if (typeof uni !== 'undefined') {
|
||||
return !exports.IN_MINI_APP;
|
||||
}
|
||||
return (typeof window !== 'undefined') && !exports.IN_MINI_APP;
|
||||
}());
|
||||
// 命名空间
|
||||
exports.APP_NAMESPACE = (function () {
|
||||
if (exports.IN_WX_MINI_APP) {
|
||||
return wx;
|
||||
}
|
||||
if (exports.IN_UNI_APP) {
|
||||
return uni;
|
||||
}
|
||||
return window;
|
||||
}());
|
||||
// eslint-disable-next-line no-mixed-operators
|
||||
const USER_AGENT = exports.IN_BROWSER && window && window.navigator && window.navigator.userAgent || '';
|
||||
const IS_ANDROID = /Android/i.test(USER_AGENT);
|
||||
const IS_WIN_PHONE = /(?:Windows Phone)/.test(USER_AGENT);
|
||||
const IS_SYMBIAN = /(?:SymbianOS)/.test(USER_AGENT);
|
||||
const IS_IOS = /iPad/i.test(USER_AGENT) || /iPhone/i.test(USER_AGENT) || /iPod/i.test(USER_AGENT);
|
||||
exports.IS_H5 = IS_ANDROID || IS_WIN_PHONE || IS_SYMBIAN || IS_IOS;
|
||||
exports.IS_PC = exports.IN_BROWSER && !exports.IS_H5;
|
||||
exports.IS_WIN = exports.IS_PC && USER_AGENT.includes('Windows NT');
|
||||
exports.IS_MAC = exports.IS_PC && USER_AGENT.includes('Mac');
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
export declare function checkLocalMP3FileExists(src: string): Promise<boolean>;
|
||||
Generated
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.checkLocalMP3FileExists = void 0;
|
||||
function checkLocalMP3FileExists(src) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (!src)
|
||||
return false;
|
||||
try {
|
||||
const response = yield new Promise((resolve, reject) => {
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open('HEAD', src, true);
|
||||
xhr.onload = () => resolve(xhr);
|
||||
xhr.onerror = () => reject(xhr);
|
||||
xhr.send();
|
||||
});
|
||||
return response.status === 200 && response.getResponseHeader('Content-Type') === 'audio/mpeg';
|
||||
}
|
||||
catch (error) {
|
||||
console.warn(error);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.checkLocalMP3FileExists = checkLocalMP3FileExists;
|
||||
Generated
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
declare const isEmpty: (input: any) => boolean;
|
||||
export default isEmpty;
|
||||
Generated
Vendored
+38
@@ -0,0 +1,38 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const common_utils_1 = require("./common-utils");
|
||||
const isEmpty = function (input) {
|
||||
// Null and Undefined...
|
||||
if (input === null || typeof (input) === 'undefined')
|
||||
return true;
|
||||
// Booleans...
|
||||
if (typeof input === 'boolean')
|
||||
return false;
|
||||
// Numbers...
|
||||
if (typeof input === 'number')
|
||||
return input === 0;
|
||||
// Strings...
|
||||
if (typeof input === 'string')
|
||||
return input.length === 0;
|
||||
// Functions...
|
||||
if (typeof input === 'function')
|
||||
return input.length === 0;
|
||||
// Arrays...
|
||||
if (Array.isArray(input))
|
||||
return input.length === 0;
|
||||
// Errors...
|
||||
if (input instanceof Error)
|
||||
return input.message === '';
|
||||
// plain object
|
||||
if ((0, common_utils_1.isPlainObject)(input)) {
|
||||
// eslint-disable-next-line
|
||||
for (const key in input) {
|
||||
if (Object.prototype.hasOwnProperty.call(input, key)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
exports.default = isEmpty;
|
||||
Generated
Vendored
+64
@@ -0,0 +1,64 @@
|
||||
/// <reference types="node" />
|
||||
/**
|
||||
* 定时器,功能:
|
||||
* 1. 支持定时执行回调 [1,n] 次,用于常规延迟、定时操作
|
||||
* @example
|
||||
* // 默认嵌套执行,count=0 无限次
|
||||
* timer.run(callback, {delay: 2000});
|
||||
* // count=1 等同于 原始setTimeout
|
||||
* timer.run(callback, {delay: 2000, count:0});
|
||||
* 2. 支持 RAF 执行回调,用于小流渲染,audio音量获取等任务,需要渲染频率稳定,支持页面退后台后,用 setTimeout 接管,最短 1s 执行一次
|
||||
* @example
|
||||
* // 默认60fps,可以根据单位时长换算,默认开启后台执行
|
||||
* timer.run('raf', callback, {fps: 60});
|
||||
* // 设置执行次数
|
||||
* timer.run('raf', callback, {fps: 60, count: 300, backgroundTask: false});
|
||||
* 3. 支持空闲任务执行回调, requestIdleCallback 在帧渲染的空闲时间执行任务,可以用于 storage 写入等低优先级的任务
|
||||
* @example
|
||||
* // 支持原生setInterval 但不推荐使用,定时任务推荐用 timeout
|
||||
* timer.run('interval', callback, {delay:2000, count:10})
|
||||
*/
|
||||
declare class Timer {
|
||||
static taskMap: Map<any, any>;
|
||||
static currentTaskID: number;
|
||||
static generateTaskID(): number;
|
||||
/**
|
||||
*
|
||||
* @param {string} taskName 'interval' 'timeout'
|
||||
* @param {function} callback
|
||||
* @param {object} options include:
|
||||
* @param {number} options.delay millisecond
|
||||
* @param {number} options.count 定时器回调执行次数,0 无限次 or n次
|
||||
* @param {boolean} options.backgroundTask 在页面静默后是否继续执行定时器
|
||||
*/
|
||||
static run(taskName: any, callback: any, options: any): any;
|
||||
/**
|
||||
* 定时循环执行回调函数
|
||||
* 可以指定循环的时间间隔
|
||||
* 可以指定循环次数
|
||||
* @param {object} taskItem
|
||||
* @param {function} callback
|
||||
* @param {*} delay
|
||||
* @param {*} count
|
||||
* @returns ID
|
||||
*/
|
||||
static interval(taskItem: any): NodeJS.Timer;
|
||||
/**
|
||||
* 延迟执行回调
|
||||
* count = 0,循环
|
||||
* count = n, 执行n次
|
||||
* @param {object} taskItem
|
||||
*
|
||||
*/
|
||||
static timeout(taskItem: any): NodeJS.Timeout;
|
||||
static hasTask(taskID: any): boolean;
|
||||
static clearTask(taskID: any): boolean;
|
||||
/**
|
||||
* 1. 如果已移除出定时队列,退出当前任务
|
||||
* 2. 如果当前任务已满足次数限制,则退出当前任务
|
||||
* @param {object} taskItem
|
||||
* @returns
|
||||
*/
|
||||
static isBreakLoop(taskItem: any): boolean;
|
||||
}
|
||||
export default Timer;
|
||||
Generated
Vendored
+154
@@ -0,0 +1,154 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
/* eslint-disable */
|
||||
const common_utils_1 = require("./common-utils");
|
||||
const index_1 = require("../const/index");
|
||||
/**
|
||||
* 定时器,功能:
|
||||
* 1. 支持定时执行回调 [1,n] 次,用于常规延迟、定时操作
|
||||
* @example
|
||||
* // 默认嵌套执行,count=0 无限次
|
||||
* timer.run(callback, {delay: 2000});
|
||||
* // count=1 等同于 原始setTimeout
|
||||
* timer.run(callback, {delay: 2000, count:0});
|
||||
* 2. 支持 RAF 执行回调,用于小流渲染,audio音量获取等任务,需要渲染频率稳定,支持页面退后台后,用 setTimeout 接管,最短 1s 执行一次
|
||||
* @example
|
||||
* // 默认60fps,可以根据单位时长换算,默认开启后台执行
|
||||
* timer.run('raf', callback, {fps: 60});
|
||||
* // 设置执行次数
|
||||
* timer.run('raf', callback, {fps: 60, count: 300, backgroundTask: false});
|
||||
* 3. 支持空闲任务执行回调, requestIdleCallback 在帧渲染的空闲时间执行任务,可以用于 storage 写入等低优先级的任务
|
||||
* @example
|
||||
* // 支持原生setInterval 但不推荐使用,定时任务推荐用 timeout
|
||||
* timer.run('interval', callback, {delay:2000, count:10})
|
||||
*/
|
||||
class Timer {
|
||||
static generateTaskID() {
|
||||
return this.currentTaskID++;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {string} taskName 'interval' 'timeout'
|
||||
* @param {function} callback
|
||||
* @param {object} options include:
|
||||
* @param {number} options.delay millisecond
|
||||
* @param {number} options.count 定时器回调执行次数,0 无限次 or n次
|
||||
* @param {boolean} options.backgroundTask 在页面静默后是否继续执行定时器
|
||||
*/
|
||||
static run(taskName = index_1.NAME.TIMEOUT, callback, options) {
|
||||
// default options
|
||||
if (taskName === index_1.NAME.INTERVAL) {
|
||||
options = Object.assign({ delay: 2000, count: 0, backgroundTask: true }, options);
|
||||
}
|
||||
else {
|
||||
options = Object.assign({ delay: 2000, count: 0, backgroundTask: true }, options);
|
||||
}
|
||||
// call run(function, {...})
|
||||
if ((0, common_utils_1.isPlainObject)(callback)) {
|
||||
options = Object.assign(Object.assign({}, options), callback);
|
||||
}
|
||||
if ((0, common_utils_1.isFunction)(taskName)) {
|
||||
callback = taskName;
|
||||
taskName = index_1.NAME.TIMEOUT;
|
||||
}
|
||||
// 1. 创建 taskID,作为 timer task 的唯一标识,在本函数执行完后返回,用于在调用的地方实现互斥逻辑
|
||||
// 2. 根据 taskName 执行相应的函数
|
||||
const taskItem = Object.assign({ taskID: this.generateTaskID(), loopCount: 0, intervalID: null, timeoutID: null, taskName,
|
||||
callback }, options);
|
||||
this.taskMap.set(taskItem.taskID, taskItem);
|
||||
// console.log(`timer run task:${taskItem.taskName}, task queue size: ${this.taskMap.size}`);
|
||||
if (taskName === index_1.NAME.INTERNAL) {
|
||||
this.interval(taskItem);
|
||||
}
|
||||
else {
|
||||
this.timeout(taskItem);
|
||||
}
|
||||
return taskItem.taskID;
|
||||
}
|
||||
/**
|
||||
* 定时循环执行回调函数
|
||||
* 可以指定循环的时间间隔
|
||||
* 可以指定循环次数
|
||||
* @param {object} taskItem
|
||||
* @param {function} callback
|
||||
* @param {*} delay
|
||||
* @param {*} count
|
||||
* @returns ID
|
||||
*/
|
||||
static interval(taskItem) {
|
||||
// setInterval 缺点,浏览器退后台会降频,循环执行间隔时间不可靠
|
||||
// 创建进入定时器循环的任务函数,函数内:1. 判断是否满足执行条件,2.执行 callback
|
||||
// 通过 setInterval 执行任务函数
|
||||
// 将 intervalID 记录到 taskMap 对应的 item
|
||||
const task = () => {
|
||||
taskItem.callback();
|
||||
taskItem.loopCount += 1;
|
||||
if (this.isBreakLoop(taskItem)) {
|
||||
return;
|
||||
}
|
||||
};
|
||||
return taskItem.intervalID = setInterval(task, taskItem.delay);
|
||||
}
|
||||
/**
|
||||
* 延迟执行回调
|
||||
* count = 0,循环
|
||||
* count = n, 执行n次
|
||||
* @param {object} taskItem
|
||||
*
|
||||
*/
|
||||
static timeout(taskItem) {
|
||||
// setTimeout 浏览器退后台,延迟变为至少1s
|
||||
const task = () => {
|
||||
// 执行回调
|
||||
taskItem.callback();
|
||||
taskItem.loopCount += 1;
|
||||
if (this.isBreakLoop(taskItem)) {
|
||||
return;
|
||||
}
|
||||
// 不修正延迟,每次callback间隔平均
|
||||
return taskItem.timeoutID = setTimeout(task, taskItem.delay);
|
||||
};
|
||||
return taskItem.timeoutID = setTimeout(task, taskItem.delay);
|
||||
}
|
||||
static hasTask(taskID) {
|
||||
return this.taskMap.has(taskID);
|
||||
}
|
||||
static clearTask(taskID) {
|
||||
// console.log('timer clearTask start', `| taskID:${taskID} | size:${this.taskMap.size}`);
|
||||
if (!this.taskMap.has(taskID)) {
|
||||
return true;
|
||||
}
|
||||
const { intervalID, timeoutID, onVisibilitychange } = this.taskMap.get(taskID);
|
||||
if (intervalID) {
|
||||
clearInterval(intervalID);
|
||||
}
|
||||
if (timeoutID) {
|
||||
clearTimeout(timeoutID);
|
||||
}
|
||||
if (onVisibilitychange) {
|
||||
document.removeEventListener('visibilitychange', onVisibilitychange);
|
||||
}
|
||||
this.taskMap.delete(taskID);
|
||||
// console.log('timer clearTask end ', `| size:${this.taskMap.size}`);
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* 1. 如果已移除出定时队列,退出当前任务
|
||||
* 2. 如果当前任务已满足次数限制,则退出当前任务
|
||||
* @param {object} taskItem
|
||||
* @returns
|
||||
*/
|
||||
static isBreakLoop(taskItem) {
|
||||
if (!this.taskMap.has(taskItem.taskID)) {
|
||||
return true;
|
||||
}
|
||||
if (taskItem.count !== 0 && taskItem.loopCount >= taskItem.count) {
|
||||
this.clearTask(taskItem.taskID);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Timer.taskMap = new Map();
|
||||
Timer.currentTaskID = 1;
|
||||
exports.default = Timer;
|
||||
Generated
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* 装饰器:阻止函数重复调用
|
||||
* @export
|
||||
* @param {Object} options 入参
|
||||
* @param {Function} options.fn 函数
|
||||
* @param {Object} options.context 上下文对象
|
||||
* @param {String} options.name 函数名
|
||||
* @returns {Function} 封装后的函数
|
||||
*/
|
||||
export declare function avoidRepeatedCall(): (target: any, name: string, descriptor: any) => any;
|
||||
Generated
Vendored
+49
@@ -0,0 +1,49 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.avoidRepeatedCall = void 0;
|
||||
const index_1 = require("../../const/index");
|
||||
/**
|
||||
* 装饰器:阻止函数重复调用
|
||||
* @export
|
||||
* @param {Object} options 入参
|
||||
* @param {Function} options.fn 函数
|
||||
* @param {Object} options.context 上下文对象
|
||||
* @param {String} options.name 函数名
|
||||
* @returns {Function} 封装后的函数
|
||||
*/
|
||||
function avoidRepeatedCall() {
|
||||
return function (target, name, descriptor) {
|
||||
const oldFn = descriptor.value;
|
||||
const isCallingSet = new Set();
|
||||
descriptor.value = function (...args) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (isCallingSet.has(this)) {
|
||||
console.warn((`${index_1.NAME.PREFIX}previous ${name}() is ongoing, please avoid repeated calls`));
|
||||
// throw new Error(`previous ${name}() is ongoing, please avoid repeated calls`);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
isCallingSet.add(this);
|
||||
const result = yield oldFn.apply(this, args);
|
||||
isCallingSet.delete(this);
|
||||
return result;
|
||||
}
|
||||
catch (error) {
|
||||
isCallingSet.delete(this);
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
};
|
||||
return descriptor;
|
||||
};
|
||||
}
|
||||
exports.avoidRepeatedCall = avoidRepeatedCall;
|
||||
Generated
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
import { avoidRepeatedCall } from './avoidRepeatedCall';
|
||||
import { paramValidate } from './validateParams';
|
||||
import { VALIDATE_PARAMS } from './validateConfig';
|
||||
export { VALIDATE_PARAMS, paramValidate, avoidRepeatedCall, };
|
||||
Generated
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.avoidRepeatedCall = exports.paramValidate = exports.VALIDATE_PARAMS = void 0;
|
||||
const avoidRepeatedCall_1 = require("./avoidRepeatedCall");
|
||||
Object.defineProperty(exports, "avoidRepeatedCall", { enumerable: true, get: function () { return avoidRepeatedCall_1.avoidRepeatedCall; } });
|
||||
const validateParams_1 = require("./validateParams");
|
||||
Object.defineProperty(exports, "paramValidate", { enumerable: true, get: function () { return validateParams_1.paramValidate; } });
|
||||
const validateConfig_1 = require("./validateConfig");
|
||||
Object.defineProperty(exports, "VALIDATE_PARAMS", { enumerable: true, get: function () { return validateConfig_1.VALIDATE_PARAMS; } });
|
||||
Generated
Vendored
+173
@@ -0,0 +1,173 @@
|
||||
import { VideoResolution, VideoDisplayMode } from "../../const/index";
|
||||
export declare const VALIDATE_PARAMS: {
|
||||
init: {
|
||||
SDKAppID: {
|
||||
required: boolean;
|
||||
rules: any[];
|
||||
allowEmpty: boolean;
|
||||
};
|
||||
userID: {
|
||||
required: boolean;
|
||||
rules: any[];
|
||||
allowEmpty: boolean;
|
||||
};
|
||||
userSig: {
|
||||
required: boolean;
|
||||
rules: any[];
|
||||
allowEmpty: boolean;
|
||||
};
|
||||
tim: {
|
||||
required: boolean;
|
||||
rules: any[];
|
||||
};
|
||||
};
|
||||
call: {
|
||||
userID: {
|
||||
required: boolean;
|
||||
rules: any[];
|
||||
allowEmpty: boolean;
|
||||
};
|
||||
type: {
|
||||
required: boolean;
|
||||
rules: any[];
|
||||
range: number[];
|
||||
allowEmpty: boolean;
|
||||
};
|
||||
roomID: {
|
||||
required: boolean;
|
||||
rules: any[];
|
||||
range: string;
|
||||
allowEmpty: boolean;
|
||||
};
|
||||
userData: {
|
||||
required: boolean;
|
||||
rules: any[];
|
||||
allowEmpty: boolean;
|
||||
};
|
||||
timeout: {
|
||||
required: boolean;
|
||||
rules: any[];
|
||||
allowEmpty: boolean;
|
||||
};
|
||||
};
|
||||
groupCall: {
|
||||
userIDList: {
|
||||
required: boolean;
|
||||
rules: any[];
|
||||
allowEmpty: boolean;
|
||||
};
|
||||
type: {
|
||||
required: boolean;
|
||||
rules: any[];
|
||||
range: number[];
|
||||
allowEmpty: boolean;
|
||||
};
|
||||
groupID: {
|
||||
required: boolean;
|
||||
rules: any[];
|
||||
allowEmpty: boolean;
|
||||
};
|
||||
roomID: {
|
||||
required: boolean;
|
||||
rules: any[];
|
||||
range: string;
|
||||
allowEmpty: boolean;
|
||||
};
|
||||
timeout: {
|
||||
required: boolean;
|
||||
rules: any[];
|
||||
allowEmpty: boolean;
|
||||
};
|
||||
userData: {
|
||||
required: boolean;
|
||||
rules: any[];
|
||||
allowEmpty: boolean;
|
||||
};
|
||||
offlinePushInfo: {
|
||||
required: boolean;
|
||||
rules: any[];
|
||||
allowEmpty: boolean;
|
||||
};
|
||||
};
|
||||
joinInGroupCall: {
|
||||
type: {
|
||||
required: boolean;
|
||||
rules: any[];
|
||||
range: number[];
|
||||
allowEmpty: boolean;
|
||||
};
|
||||
groupID: {
|
||||
required: boolean;
|
||||
rules: any[];
|
||||
allowEmpty: boolean;
|
||||
};
|
||||
roomID: {
|
||||
required: boolean;
|
||||
rules: any[];
|
||||
allowEmpty: boolean;
|
||||
};
|
||||
};
|
||||
inviteUser: {
|
||||
userIDList: {
|
||||
required: boolean;
|
||||
rules: any[];
|
||||
allowEmpty: boolean;
|
||||
};
|
||||
};
|
||||
setSelfInfo: {
|
||||
nickName: {
|
||||
required: boolean;
|
||||
rules: any[];
|
||||
allowEmpty: boolean;
|
||||
};
|
||||
avatar: {
|
||||
required: boolean;
|
||||
rules: any[];
|
||||
allowEmpty: boolean;
|
||||
};
|
||||
};
|
||||
enableFloatWindow: {
|
||||
key: string;
|
||||
required: boolean;
|
||||
rules: any[];
|
||||
allowEmpty: boolean;
|
||||
}[];
|
||||
enableAIVoice: {
|
||||
key: string;
|
||||
required: boolean;
|
||||
rules: any[];
|
||||
allowEmpty: boolean;
|
||||
}[];
|
||||
enableMuteMode: {
|
||||
key: string;
|
||||
required: boolean;
|
||||
rules: any[];
|
||||
allowEmpty: boolean;
|
||||
}[];
|
||||
setCallingBell: {
|
||||
key: string;
|
||||
required: boolean;
|
||||
rules: any[];
|
||||
allowEmpty: boolean;
|
||||
}[];
|
||||
setLanguage: {
|
||||
key: string;
|
||||
required: boolean;
|
||||
rules: any[];
|
||||
allowEmpty: boolean;
|
||||
}[];
|
||||
setVideoDisplayMode: {
|
||||
key: string;
|
||||
required: boolean;
|
||||
rules: any[];
|
||||
range: VideoDisplayMode[];
|
||||
allowEmpty: boolean;
|
||||
}[];
|
||||
setVideoResolution: {
|
||||
key: string;
|
||||
required: boolean;
|
||||
rules: any[];
|
||||
range: VideoResolution[];
|
||||
allowEmpty: boolean;
|
||||
}[];
|
||||
};
|
||||
Generated
Vendored
+190
@@ -0,0 +1,190 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.VALIDATE_PARAMS = void 0;
|
||||
const index_1 = require("../../const/index");
|
||||
exports.VALIDATE_PARAMS = {
|
||||
init: {
|
||||
SDKAppID: {
|
||||
required: true,
|
||||
rules: [index_1.NAME.NUMBER],
|
||||
allowEmpty: false,
|
||||
},
|
||||
userID: {
|
||||
required: true,
|
||||
rules: [index_1.NAME.STRING],
|
||||
allowEmpty: false,
|
||||
},
|
||||
userSig: {
|
||||
required: true,
|
||||
rules: [index_1.NAME.STRING],
|
||||
allowEmpty: false,
|
||||
},
|
||||
tim: {
|
||||
required: false,
|
||||
rules: [index_1.NAME.OBJECT],
|
||||
},
|
||||
},
|
||||
call: {
|
||||
userID: {
|
||||
required: true,
|
||||
rules: [index_1.NAME.STRING],
|
||||
allowEmpty: false
|
||||
},
|
||||
type: {
|
||||
required: true,
|
||||
rules: [index_1.NAME.NUMBER],
|
||||
range: [1, 2],
|
||||
allowEmpty: false
|
||||
},
|
||||
roomID: {
|
||||
required: false,
|
||||
rules: [index_1.NAME.NUMBER],
|
||||
range: `1~${index_1.MAX_NUMBER_ROOM_ID}`,
|
||||
allowEmpty: false,
|
||||
},
|
||||
userData: {
|
||||
required: false,
|
||||
rules: [index_1.NAME.STRING],
|
||||
allowEmpty: false,
|
||||
},
|
||||
timeout: {
|
||||
required: false,
|
||||
rules: [index_1.NAME.NUMBER],
|
||||
allowEmpty: false
|
||||
}
|
||||
},
|
||||
groupCall: {
|
||||
userIDList: {
|
||||
required: true,
|
||||
rules: [index_1.NAME.ARRAY],
|
||||
allowEmpty: false
|
||||
},
|
||||
type: {
|
||||
required: true,
|
||||
rules: [index_1.NAME.NUMBER],
|
||||
range: [1, 2],
|
||||
allowEmpty: false
|
||||
},
|
||||
groupID: {
|
||||
required: true,
|
||||
rules: [index_1.NAME.STRING],
|
||||
allowEmpty: false
|
||||
},
|
||||
roomID: {
|
||||
required: false,
|
||||
rules: [index_1.NAME.NUMBER],
|
||||
range: `1~${index_1.MAX_NUMBER_ROOM_ID}`,
|
||||
allowEmpty: false
|
||||
},
|
||||
timeout: {
|
||||
required: false,
|
||||
rules: [index_1.NAME.NUMBER],
|
||||
allowEmpty: false
|
||||
},
|
||||
userData: {
|
||||
required: false,
|
||||
rules: [index_1.NAME.STRING],
|
||||
allowEmpty: false,
|
||||
},
|
||||
offlinePushInfo: {
|
||||
required: false,
|
||||
rules: [index_1.NAME.OBJECT],
|
||||
allowEmpty: false,
|
||||
},
|
||||
},
|
||||
joinInGroupCall: {
|
||||
type: {
|
||||
required: true,
|
||||
rules: [index_1.NAME.NUMBER],
|
||||
range: [1, 2],
|
||||
allowEmpty: false
|
||||
},
|
||||
groupID: {
|
||||
required: true,
|
||||
rules: [index_1.NAME.STRING],
|
||||
allowEmpty: false
|
||||
},
|
||||
roomID: {
|
||||
required: true,
|
||||
rules: [index_1.NAME.NUMBER],
|
||||
allowEmpty: false,
|
||||
},
|
||||
},
|
||||
inviteUser: {
|
||||
userIDList: {
|
||||
required: true,
|
||||
rules: [index_1.NAME.ARRAY],
|
||||
allowEmpty: false
|
||||
},
|
||||
},
|
||||
setSelfInfo: {
|
||||
nickName: {
|
||||
required: false,
|
||||
rules: [index_1.NAME.STRING],
|
||||
allowEmpty: false,
|
||||
},
|
||||
avatar: {
|
||||
required: false,
|
||||
rules: [index_1.NAME.STRING],
|
||||
allowEmpty: false,
|
||||
}
|
||||
},
|
||||
enableFloatWindow: [
|
||||
{
|
||||
key: "enable",
|
||||
required: false,
|
||||
rules: [index_1.NAME.BOOLEAN],
|
||||
allowEmpty: false,
|
||||
}
|
||||
],
|
||||
enableAIVoice: [
|
||||
{
|
||||
key: "enable",
|
||||
required: true,
|
||||
rules: [index_1.NAME.BOOLEAN],
|
||||
allowEmpty: false,
|
||||
}
|
||||
],
|
||||
enableMuteMode: [
|
||||
{
|
||||
key: "enable",
|
||||
required: true,
|
||||
rules: [index_1.NAME.BOOLEAN],
|
||||
allowEmpty: false,
|
||||
}
|
||||
],
|
||||
setCallingBell: [
|
||||
{
|
||||
key: "filePath",
|
||||
required: false,
|
||||
rules: [index_1.NAME.STRING],
|
||||
allowEmpty: true,
|
||||
}
|
||||
],
|
||||
setLanguage: [
|
||||
{
|
||||
key: "language",
|
||||
required: true,
|
||||
rules: [index_1.NAME.STRING],
|
||||
allowEmpty: false
|
||||
}
|
||||
],
|
||||
setVideoDisplayMode: [
|
||||
{
|
||||
key: "displayMode",
|
||||
required: true,
|
||||
rules: [index_1.NAME.STRING],
|
||||
range: [index_1.VideoDisplayMode.CONTAIN, index_1.VideoDisplayMode.COVER, index_1.VideoDisplayMode.FILL],
|
||||
allowEmpty: false
|
||||
}
|
||||
],
|
||||
setVideoResolution: [
|
||||
{
|
||||
key: "resolution",
|
||||
required: true,
|
||||
rules: [index_1.NAME.STRING],
|
||||
range: [index_1.VideoResolution.RESOLUTION_1080P, index_1.VideoResolution.RESOLUTION_480P, index_1.VideoResolution.RESOLUTION_720P],
|
||||
allowEmpty: false
|
||||
}
|
||||
]
|
||||
};
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
export declare function paramValidate(config: any): (target: any, propertyName: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
||||
Generated
Vendored
+86
@@ -0,0 +1,86 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.paramValidate = void 0;
|
||||
const common_utils_1 = require("../common-utils");
|
||||
const index_1 = require("../../const/index");
|
||||
const PREFIX = index_1.NAME.PREFIX + "API";
|
||||
function paramValidate(config) {
|
||||
return function (target, propertyName, descriptor) {
|
||||
let method = descriptor.value;
|
||||
descriptor.value = function (...args) {
|
||||
doValidate.call(this, config, args, propertyName);
|
||||
return method.apply(this, args);
|
||||
};
|
||||
return descriptor;
|
||||
};
|
||||
}
|
||||
exports.paramValidate = paramValidate;
|
||||
function doValidate(config, args, name) {
|
||||
try {
|
||||
// 兼容 init 方法中: SDKAppID sdkAppID 两种写法的参数校验判断
|
||||
if (!args[0].SDKAppID) {
|
||||
config = (0, common_utils_1.modifyObjectKey)(config, "SDKAppID", "sdkAppID");
|
||||
}
|
||||
if ((0, common_utils_1.isArray)(config)) {
|
||||
for (let i = 0; i < config.length; i++) {
|
||||
check.call(this, Object.assign(Object.assign({}, config[i]), { value: args[i], name }));
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (const key in config) {
|
||||
if (config.hasOwnProperty(key)) {
|
||||
check.call(this, Object.assign(Object.assign({}, config[key]), { value: args[0][key], name,
|
||||
key }));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
console.error(error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
function check({ required, rules, range, value, allowEmpty, name, key }) {
|
||||
// 用户没传指定参数
|
||||
if ((0, common_utils_1.isUndefined)(value)) {
|
||||
// 检查必填参数, 若配置是必填则报错
|
||||
if (required) {
|
||||
throw new Error(`${PREFIX}<${name}>: ${key} is required.`);
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
// 判断参数类型是否正确
|
||||
const result = rules.some((item) => item === (0, common_utils_1.getType)(value));
|
||||
let type = '';
|
||||
if (!result) {
|
||||
for (let i = 0; i < rules.length; i++) {
|
||||
let str = rules[i];
|
||||
str = str.replace(str[0], str[0].toUpperCase());
|
||||
type += `${str}/`;
|
||||
}
|
||||
type = type.substring(0, type.length - 1);
|
||||
throw new Error(`${PREFIX}<${name}>: ${key} must be ${type}, current ${key} is ${typeof value}.`);
|
||||
}
|
||||
// 不允许传空值, 例如: '', ' '
|
||||
if (allowEmpty === false) {
|
||||
const isEmptyString = (0, common_utils_1.isString)(value) && value.trim() === '';
|
||||
if (isEmptyString) {
|
||||
throw new Error(`${PREFIX}<${name}>: ${key} is blank.`);
|
||||
}
|
||||
}
|
||||
// 判断是否符合限制条件
|
||||
if ((0, common_utils_1.isArray)(range)) {
|
||||
if (range && range.indexOf(value) === -1) {
|
||||
throw new Error(`${PREFIX}<${name}>: ${key} error, only be ${range}, current ${key} is ${value}.`);
|
||||
}
|
||||
}
|
||||
// 取值范围, 前闭后闭
|
||||
if ((0, common_utils_1.isString)(range) && range.indexOf('~') !== -1) {
|
||||
const valueList = range.split('~');
|
||||
if (value < +valueList[0] || value > +valueList[1] || ((0, common_utils_1.isNumber)(value) && Number.isNaN(value))) {
|
||||
throw new Error(`${PREFIX}<${name}>: ${key} error, only be ${range}, current ${key} is ${value}.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user