@coze/realtime-api 1.2.0 → 1.2.1-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/event-names/index.js +53 -1
- package/dist/cjs/index.js +125 -37
- package/dist/esm/event-names/index.js +53 -1
- package/dist/esm/index.js +125 -37
- package/dist/types/client.d.ts +1 -0
- package/dist/types/event-names/client.d.ts +1 -0
- package/dist/types/event-names/event-names.d.ts +66 -1
- package/dist/types/event-names/index.d.ts +11 -2
- package/dist/types/event-names/utils.d.ts +6 -0
- package/dist/types/event-names.d.ts +66 -1
- package/dist/types/index.d.ts +11 -2
- package/dist/types/utils.d.ts +6 -0
- package/dist/umd/index.js +125 -37
- package/package.json +5 -5
@@ -49,6 +49,10 @@ var EventNames = /*#__PURE__*/ function(EventNames) {
|
|
49
49
|
* zh: 所有服务端事件
|
50
50
|
*/ EventNames["ALL_SERVER"] = "server.*";
|
51
51
|
/**
|
52
|
+
* en: Room info
|
53
|
+
* zh: 房间信息
|
54
|
+
*/ EventNames["ROOM_INFO"] = "client.room.info";
|
55
|
+
/**
|
52
56
|
* en: Client connected
|
53
57
|
* zh: 客户端连接
|
54
58
|
*/ EventNames["CONNECTED"] = "client.connected";
|
@@ -81,6 +85,10 @@ var EventNames = /*#__PURE__*/ function(EventNames) {
|
|
81
85
|
* zh: 客户端视频关闭
|
82
86
|
*/ EventNames["VIDEO_OFF"] = "client.video.off";
|
83
87
|
/**
|
88
|
+
* en: Client video error
|
89
|
+
* zh: 客户端视频(或屏幕共享)错误
|
90
|
+
*/ EventNames["VIDEO_ERROR"] = "client.video.error";
|
91
|
+
/**
|
84
92
|
* en: Client video event
|
85
93
|
* zh: 客户端视频事件
|
86
94
|
*/ EventNames["PLAYER_EVENT"] = "client.video.event";
|
@@ -147,7 +155,51 @@ var EventNames = /*#__PURE__*/ function(EventNames) {
|
|
147
155
|
/**
|
148
156
|
* en: Session updated
|
149
157
|
* zh: 会话更新
|
150
|
-
*/ EventNames["
|
158
|
+
*/ EventNames["SESSION_UPDATED"] = "server.session.updated";
|
159
|
+
/**
|
160
|
+
* en: Conversation created
|
161
|
+
* zh: 会话创建
|
162
|
+
*/ EventNames["CONVERSATION_CREATED"] = "server.conversation.created";
|
163
|
+
/**
|
164
|
+
* en: Conversation chat created
|
165
|
+
* zh: 会话对话创建
|
166
|
+
*/ EventNames["CONVERSATION_CHAT_CREATED"] = "server.conversation.chat.created";
|
167
|
+
/**
|
168
|
+
* en: Conversation chat in progress
|
169
|
+
* zh: 对话正在处理中
|
170
|
+
*/ EventNames["CONVERSATION_CHAT_IN_PROGRESS"] = "server.conversation.chat.in_progress";
|
171
|
+
/**
|
172
|
+
* en: Conversation message delta received
|
173
|
+
* zh: 文本消息增量返回
|
174
|
+
*/ EventNames["CONVERSATION_MESSAGE_DELTA"] = "server.conversation.message.delta";
|
175
|
+
/**
|
176
|
+
* en: Conversation message completed
|
177
|
+
* zh: 文本消息完成
|
178
|
+
*/ EventNames["CONVERSATION_MESSAGE_COMPLETED"] = "server.conversation.message.completed";
|
179
|
+
/**
|
180
|
+
* en: Conversation chat completed
|
181
|
+
* zh: 对话完成
|
182
|
+
*/ EventNames["CONVERSATION_CHAT_COMPLETED"] = "server.conversation.chat.completed";
|
183
|
+
/**
|
184
|
+
* en: Conversation chat requires action
|
185
|
+
* zh: 对话需要插件
|
186
|
+
*/ EventNames["CONVERSATION_CHAT_REQUIRES_ACTION"] = "server.conversation.chat.requires_action";
|
187
|
+
/**
|
188
|
+
* en: Conversation chat failed
|
189
|
+
* zh: 对话失败
|
190
|
+
*/ EventNames["CONVERSATION_CHAT_FAILED"] = "server.conversation.chat.failed";
|
191
|
+
/**
|
192
|
+
* en: Session pre answer updated
|
193
|
+
* zh: 安抚配置更新成功
|
194
|
+
*/ EventNames["SESSION_PRE_ANSWER_UPDATED"] = "server.session.pre_answer.updated";
|
195
|
+
/**
|
196
|
+
* en: Conversation audio transcript delta
|
197
|
+
* zh: 用户语音识别字幕
|
198
|
+
*/ EventNames["CONVERSATION_AUDIO_TRANSCRIPT_DELTA"] = "server.conversation.audio_transcript.delta";
|
199
|
+
/**
|
200
|
+
* en: Mode updated
|
201
|
+
* zh: 更新房间模式成功
|
202
|
+
*/ EventNames["MODE_UPDATED"] = "server.mode.updated";
|
151
203
|
return EventNames;
|
152
204
|
}(EventNames || {});
|
153
205
|
/* ESM default export */ const __WEBPACK_DEFAULT_EXPORT__ = EventNames;
|
package/dist/cjs/index.js
CHANGED
@@ -61,6 +61,7 @@ __webpack_require__.d(utils_namespaceObject, {
|
|
61
61
|
checkDevicePermission: ()=>checkDevicePermission,
|
62
62
|
checkPermission: ()=>checkPermission,
|
63
63
|
getAudioDevices: ()=>getAudioDevices,
|
64
|
+
isMobileVideoDevice: ()=>isMobileVideoDevice,
|
64
65
|
isScreenShareDevice: ()=>isScreenShareDevice,
|
65
66
|
isScreenShareSupported: ()=>isScreenShareSupported,
|
66
67
|
sleep: ()=>sleep
|
@@ -135,6 +136,11 @@ var rtc_default = /*#__PURE__*/ __webpack_require__.n(rtc_namespaceObject);
|
|
135
136
|
};
|
136
137
|
};
|
137
138
|
const isScreenShareDevice = (deviceId)=>'screenShare' === deviceId;
|
139
|
+
/**
|
140
|
+
* 判断是否前后置摄像头
|
141
|
+
* @param deviceId
|
142
|
+
* @returns
|
143
|
+
*/ const isMobileVideoDevice = (deviceId)=>'user' === deviceId || 'environment' === deviceId;
|
138
144
|
/**
|
139
145
|
* Check if browser supports screen sharing
|
140
146
|
* 检查浏览器是否支持屏幕共享
|
@@ -156,6 +162,10 @@ var event_names_EventNames = /*#__PURE__*/ function(EventNames) {
|
|
156
162
|
* zh: 所有服务端事件
|
157
163
|
*/ EventNames["ALL_SERVER"] = "server.*";
|
158
164
|
/**
|
165
|
+
* en: Room info
|
166
|
+
* zh: 房间信息
|
167
|
+
*/ EventNames["ROOM_INFO"] = "client.room.info";
|
168
|
+
/**
|
159
169
|
* en: Client connected
|
160
170
|
* zh: 客户端连接
|
161
171
|
*/ EventNames["CONNECTED"] = "client.connected";
|
@@ -188,6 +198,10 @@ var event_names_EventNames = /*#__PURE__*/ function(EventNames) {
|
|
188
198
|
* zh: 客户端视频关闭
|
189
199
|
*/ EventNames["VIDEO_OFF"] = "client.video.off";
|
190
200
|
/**
|
201
|
+
* en: Client video error
|
202
|
+
* zh: 客户端视频(或屏幕共享)错误
|
203
|
+
*/ EventNames["VIDEO_ERROR"] = "client.video.error";
|
204
|
+
/**
|
191
205
|
* en: Client video event
|
192
206
|
* zh: 客户端视频事件
|
193
207
|
*/ EventNames["PLAYER_EVENT"] = "client.video.event";
|
@@ -254,7 +268,51 @@ var event_names_EventNames = /*#__PURE__*/ function(EventNames) {
|
|
254
268
|
/**
|
255
269
|
* en: Session updated
|
256
270
|
* zh: 会话更新
|
257
|
-
*/ EventNames["
|
271
|
+
*/ EventNames["SESSION_UPDATED"] = "server.session.updated";
|
272
|
+
/**
|
273
|
+
* en: Conversation created
|
274
|
+
* zh: 会话创建
|
275
|
+
*/ EventNames["CONVERSATION_CREATED"] = "server.conversation.created";
|
276
|
+
/**
|
277
|
+
* en: Conversation chat created
|
278
|
+
* zh: 会话对话创建
|
279
|
+
*/ EventNames["CONVERSATION_CHAT_CREATED"] = "server.conversation.chat.created";
|
280
|
+
/**
|
281
|
+
* en: Conversation chat in progress
|
282
|
+
* zh: 对话正在处理中
|
283
|
+
*/ EventNames["CONVERSATION_CHAT_IN_PROGRESS"] = "server.conversation.chat.in_progress";
|
284
|
+
/**
|
285
|
+
* en: Conversation message delta received
|
286
|
+
* zh: 文本消息增量返回
|
287
|
+
*/ EventNames["CONVERSATION_MESSAGE_DELTA"] = "server.conversation.message.delta";
|
288
|
+
/**
|
289
|
+
* en: Conversation message completed
|
290
|
+
* zh: 文本消息完成
|
291
|
+
*/ EventNames["CONVERSATION_MESSAGE_COMPLETED"] = "server.conversation.message.completed";
|
292
|
+
/**
|
293
|
+
* en: Conversation chat completed
|
294
|
+
* zh: 对话完成
|
295
|
+
*/ EventNames["CONVERSATION_CHAT_COMPLETED"] = "server.conversation.chat.completed";
|
296
|
+
/**
|
297
|
+
* en: Conversation chat requires action
|
298
|
+
* zh: 对话需要插件
|
299
|
+
*/ EventNames["CONVERSATION_CHAT_REQUIRES_ACTION"] = "server.conversation.chat.requires_action";
|
300
|
+
/**
|
301
|
+
* en: Conversation chat failed
|
302
|
+
* zh: 对话失败
|
303
|
+
*/ EventNames["CONVERSATION_CHAT_FAILED"] = "server.conversation.chat.failed";
|
304
|
+
/**
|
305
|
+
* en: Session pre answer updated
|
306
|
+
* zh: 安抚配置更新成功
|
307
|
+
*/ EventNames["SESSION_PRE_ANSWER_UPDATED"] = "server.session.pre_answer.updated";
|
308
|
+
/**
|
309
|
+
* en: Conversation audio transcript delta
|
310
|
+
* zh: 用户语音识别字幕
|
311
|
+
*/ EventNames["CONVERSATION_AUDIO_TRANSCRIPT_DELTA"] = "server.conversation.audio_transcript.delta";
|
312
|
+
/**
|
313
|
+
* en: Mode updated
|
314
|
+
* zh: 更新房间模式成功
|
315
|
+
*/ EventNames["MODE_UPDATED"] = "server.mode.updated";
|
258
316
|
return EventNames;
|
259
317
|
}(event_names_EventNames || {});
|
260
318
|
/* ESM default export */ const event_names = event_names_EventNames;
|
@@ -344,6 +402,7 @@ class EngineClient extends RealtimeEventHandler {
|
|
344
402
|
this.engine.on(rtc_default().events.onUserLeave, this.handleUserLeave);
|
345
403
|
this.engine.on(rtc_default().events.onError, this.handleEventError);
|
346
404
|
this.engine.on(rtc_default().events.onNetworkQuality, this.handleNetworkQuality);
|
405
|
+
this.engine.on(rtc_default().events.onTrackEnded, this.handleTrackEnded);
|
347
406
|
if (this._isSupportVideo) this.engine.on(rtc_default().events.onPlayerEvent, this.handlePlayerEvent);
|
348
407
|
if (this._debug) {
|
349
408
|
this.engine.on(rtc_default().events.onLocalAudioPropertiesReport, this.handleLocalAudioPropertiesReport);
|
@@ -356,6 +415,7 @@ class EngineClient extends RealtimeEventHandler {
|
|
356
415
|
this.engine.off(rtc_default().events.onUserLeave, this.handleUserLeave);
|
357
416
|
this.engine.off(rtc_default().events.onError, this.handleEventError);
|
358
417
|
this.engine.off(rtc_default().events.onNetworkQuality, this.handleNetworkQuality);
|
418
|
+
this.engine.off(rtc_default().events.onTrackEnded, this.handleTrackEnded);
|
359
419
|
if (this._isSupportVideo) this.engine.off(rtc_default().events.onPlayerEvent, this.handlePlayerEvent);
|
360
420
|
if (this._debug) {
|
361
421
|
this.engine.off(rtc_default().events.onLocalAudioPropertiesReport, this.handleLocalAudioPropertiesReport);
|
@@ -406,6 +466,10 @@ class EngineClient extends RealtimeEventHandler {
|
|
406
466
|
downlinkNetworkQuality
|
407
467
|
});
|
408
468
|
}
|
469
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
470
|
+
handleTrackEnded(event) {
|
471
|
+
if ((null == event ? void 0 : event.kind) === 'video') this.dispatch(event_names.VIDEO_OFF, event);
|
472
|
+
}
|
409
473
|
async joinRoom(options) {
|
410
474
|
const { token, roomId, uid, audioMutedDefault, videoOnDefault, isAutoSubscribeAudio } = options;
|
411
475
|
try {
|
@@ -439,7 +503,11 @@ class EngineClient extends RealtimeEventHandler {
|
|
439
503
|
const devices = await getAudioDevices({
|
440
504
|
video: true
|
441
505
|
});
|
442
|
-
if (-1 === devices.videoInputs.findIndex((i)=>i.deviceId === deviceId)) throw new RealtimeAPIError(error_RealtimeError.DEVICE_ACCESS_ERROR, `Video input device not found: ${deviceId}`);
|
506
|
+
if (!isMobileVideoDevice(deviceId) && -1 === devices.videoInputs.findIndex((i)=>i.deviceId === deviceId)) throw new RealtimeAPIError(error_RealtimeError.DEVICE_ACCESS_ERROR, `Video input device not found: ${deviceId}`);
|
507
|
+
this.engine.setLocalVideoPlayer(isScreenShareDevice(deviceId) ? rtc_namespaceObject.StreamIndex.STREAM_INDEX_SCREEN : rtc_namespaceObject.StreamIndex.STREAM_INDEX_MAIN, {
|
508
|
+
renderDom: (null === (_this__videoConfig = this._videoConfig) || void 0 === _this__videoConfig ? void 0 : _this__videoConfig.renderDom) || 'local-player',
|
509
|
+
userId: this._roomUserId
|
510
|
+
});
|
443
511
|
await this.changeVideoState(false);
|
444
512
|
if (isScreenShareDevice(deviceId)) {
|
445
513
|
if (this._streamIndex === rtc_namespaceObject.StreamIndex.STREAM_INDEX_MAIN) this.engine.setLocalVideoPlayer(rtc_namespaceObject.StreamIndex.STREAM_INDEX_MAIN);
|
@@ -455,10 +523,6 @@ class EngineClient extends RealtimeEventHandler {
|
|
455
523
|
if (isAutoCapture) await this.engine.startVideoCapture(deviceId);
|
456
524
|
this._streamIndex = rtc_namespaceObject.StreamIndex.STREAM_INDEX_MAIN;
|
457
525
|
}
|
458
|
-
this.engine.setLocalVideoPlayer(this._streamIndex, {
|
459
|
-
renderDom: (null === (_this__videoConfig = this._videoConfig) || void 0 === _this__videoConfig ? void 0 : _this__videoConfig.renderDom) || 'local-player',
|
460
|
-
userId: this._roomUserId
|
461
|
-
});
|
462
526
|
}
|
463
527
|
async createLocalStream(userId, videoConfig) {
|
464
528
|
this._roomUserId = userId;
|
@@ -468,7 +532,12 @@ class EngineClient extends RealtimeEventHandler {
|
|
468
532
|
if (!devices.audioInputs.length) throw new RealtimeAPIError(error_RealtimeError.DEVICE_ACCESS_ERROR, 'Failed to get audio devices');
|
469
533
|
if (this._isSupportVideo && !devices.videoInputs.length) throw new RealtimeAPIError(error_RealtimeError.DEVICE_ACCESS_ERROR, 'Failed to get video devices');
|
470
534
|
await this.engine.startAudioCapture(devices.audioInputs[0].deviceId);
|
471
|
-
if (this._isSupportVideo)
|
535
|
+
if (this._isSupportVideo) try {
|
536
|
+
await this.setVideoInputDevice((null == videoConfig ? void 0 : videoConfig.videoInputDeviceId) || devices.videoInputs[0].deviceId, null == videoConfig ? void 0 : videoConfig.videoOnDefault);
|
537
|
+
this.dispatch((null == videoConfig ? void 0 : videoConfig.videoOnDefault) ? event_names.VIDEO_ON : event_names.VIDEO_OFF, {});
|
538
|
+
} catch (e) {
|
539
|
+
this.dispatch(event_names.VIDEO_ERROR, e);
|
540
|
+
}
|
472
541
|
}
|
473
542
|
async disconnect() {
|
474
543
|
try {
|
@@ -491,23 +560,18 @@ class EngineClient extends RealtimeEventHandler {
|
|
491
560
|
}
|
492
561
|
}
|
493
562
|
async changeVideoState(isVideoOn) {
|
494
|
-
|
495
|
-
if (
|
496
|
-
if (this._streamIndex === rtc_namespaceObject.StreamIndex.STREAM_INDEX_MAIN) await this.engine.startVideoCapture();
|
497
|
-
else {
|
498
|
-
var _this__videoConfig;
|
499
|
-
this.engine.setVideoSourceType(rtc_namespaceObject.StreamIndex.STREAM_INDEX_SCREEN, rtc_namespaceObject.VideoSourceType.VIDEO_SOURCE_TYPE_INTERNAL);
|
500
|
-
await this.engine.startScreenCapture(null === (_this__videoConfig = this._videoConfig) || void 0 === _this__videoConfig ? void 0 : _this__videoConfig.screenConfig);
|
501
|
-
await this.engine.publishScreen(rtc_namespaceObject.MediaType.VIDEO);
|
502
|
-
}
|
503
|
-
} else if (this._streamIndex === rtc_namespaceObject.StreamIndex.STREAM_INDEX_MAIN) await this.engine.stopVideoCapture();
|
563
|
+
if (isVideoOn) {
|
564
|
+
if (this._streamIndex === rtc_namespaceObject.StreamIndex.STREAM_INDEX_MAIN) await this.engine.startVideoCapture();
|
504
565
|
else {
|
505
|
-
|
506
|
-
|
566
|
+
var _this__videoConfig;
|
567
|
+
this.engine.setVideoSourceType(rtc_namespaceObject.StreamIndex.STREAM_INDEX_SCREEN, rtc_namespaceObject.VideoSourceType.VIDEO_SOURCE_TYPE_INTERNAL);
|
568
|
+
await this.engine.startScreenCapture(null === (_this__videoConfig = this._videoConfig) || void 0 === _this__videoConfig ? void 0 : _this__videoConfig.screenConfig);
|
569
|
+
await this.engine.publishScreen(rtc_namespaceObject.MediaType.VIDEO);
|
507
570
|
}
|
508
|
-
}
|
509
|
-
|
510
|
-
|
571
|
+
} else if (this._streamIndex === rtc_namespaceObject.StreamIndex.STREAM_INDEX_MAIN) await this.engine.stopVideoCapture();
|
572
|
+
else {
|
573
|
+
await this.engine.stopScreenCapture();
|
574
|
+
await this.engine.unpublishScreen(rtc_namespaceObject.MediaType.VIDEO);
|
511
575
|
}
|
512
576
|
}
|
513
577
|
async stop() {
|
@@ -597,6 +661,7 @@ class EngineClient extends RealtimeEventHandler {
|
|
597
661
|
this.handleEventError = this.handleEventError.bind(this);
|
598
662
|
this.handlePlayerEvent = this.handlePlayerEvent.bind(this);
|
599
663
|
this.handleNetworkQuality = this.handleNetworkQuality.bind(this);
|
664
|
+
this.handleTrackEnded = this.handleTrackEnded.bind(this);
|
600
665
|
// Debug only
|
601
666
|
this.handleLocalAudioPropertiesReport = this.handleLocalAudioPropertiesReport.bind(this);
|
602
667
|
this.handleRemoteAudioPropertiesReport = this.handleRemoteAudioPropertiesReport.bind(this);
|
@@ -620,16 +685,17 @@ class RealtimeClient extends RealtimeEventHandler {
|
|
620
685
|
// Step1 get token
|
621
686
|
if (getRoomInfo) roomInfo = await getRoomInfo();
|
622
687
|
else {
|
623
|
-
|
624
|
-
if (this._config.
|
625
|
-
|
688
|
+
const config = {};
|
689
|
+
if (this._config.prologueContent) config.prologue_content = this._config.prologueContent;
|
690
|
+
if (void 0 !== this._config.roomMode && null !== this._config.roomMode) config.room_mode = this._config.roomMode;
|
691
|
+
if (this._config.videoConfig) {
|
692
|
+
if (isScreenShareDevice(this._config.videoConfig.videoInputDeviceId)) config.video_config = {
|
626
693
|
stream_video_type: 'screen'
|
627
|
-
}
|
628
|
-
|
629
|
-
video_config: {
|
694
|
+
};
|
695
|
+
else config.video_config = {
|
630
696
|
stream_video_type: 'main'
|
631
|
-
}
|
632
|
-
}
|
697
|
+
};
|
698
|
+
}
|
633
699
|
roomInfo = await this._api.audio.rooms.create({
|
634
700
|
bot_id: botId,
|
635
701
|
conversation_id: conversationId || void 0,
|
@@ -644,6 +710,12 @@ class RealtimeClient extends RealtimeEventHandler {
|
|
644
710
|
this.dispatch(event_names.ERROR, error);
|
645
711
|
throw new RealtimeAPIError(error_RealtimeError.CREATE_ROOM_ERROR, error instanceof Error ? error.message : 'Unknown error', error);
|
646
712
|
}
|
713
|
+
this.dispatch(event_names.ROOM_INFO, {
|
714
|
+
roomId: roomInfo.room_id,
|
715
|
+
uid: roomInfo.uid,
|
716
|
+
token: roomInfo.token,
|
717
|
+
appId: roomInfo.app_id
|
718
|
+
});
|
647
719
|
this._isTestEnv = TEST_APP_ID === roomInfo.app_id;
|
648
720
|
// Step2 create engine
|
649
721
|
this._client = new EngineClient(roomInfo.app_id, this._config.debug, this._isTestEnv, this._isSupportVideo, this._config.videoConfig);
|
@@ -725,10 +797,14 @@ class RealtimeClient extends RealtimeEventHandler {
|
|
725
797
|
else this.dispatch(event_names.AUDIO_MUTED, {});
|
726
798
|
}
|
727
799
|
async setVideoEnable(isEnable) {
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
800
|
+
try {
|
801
|
+
var _this__client;
|
802
|
+
await (null === (_this__client = this._client) || void 0 === _this__client ? void 0 : _this__client.changeVideoState(isEnable));
|
803
|
+
this.dispatch(isEnable ? event_names.VIDEO_ON : event_names.VIDEO_OFF, {});
|
804
|
+
} catch (e) {
|
805
|
+
this.dispatch(event_names.VIDEO_ERROR, e);
|
806
|
+
throw e;
|
807
|
+
}
|
732
808
|
}
|
733
809
|
/**
|
734
810
|
* en: Enable audio properties reporting (debug mode only)
|
@@ -785,9 +861,19 @@ class RealtimeClient extends RealtimeEventHandler {
|
|
785
861
|
deviceId
|
786
862
|
});
|
787
863
|
}
|
788
|
-
|
789
|
-
|
790
|
-
|
864
|
+
/**
|
865
|
+
* en: Set the video input device
|
866
|
+
*
|
867
|
+
* zh: 设置视频输入设备
|
868
|
+
*/ async setVideoInputDevice(deviceId) {
|
869
|
+
try {
|
870
|
+
var _this__client;
|
871
|
+
await (null === (_this__client = this._client) || void 0 === _this__client ? void 0 : _this__client.setVideoInputDevice(deviceId));
|
872
|
+
this.dispatch(event_names.VIDEO_ON, {});
|
873
|
+
} catch (e) {
|
874
|
+
this.dispatch(event_names.VIDEO_ERROR, e);
|
875
|
+
throw e;
|
876
|
+
}
|
791
877
|
this.dispatch(event_names.VIDEO_INPUT_DEVICE_CHANGED, {
|
792
878
|
deviceId
|
793
879
|
});
|
@@ -842,6 +928,8 @@ class RealtimeClient extends RealtimeEventHandler {
|
|
842
928
|
* 可选,视频输入设备的设备 ID。
|
843
929
|
* @param config.videoConfig.screenConfig - Optional, Screen share configuration if videoInputDeviceId is 'screenShare' see https://www.volcengine.com/docs/6348/104481#screenconfig for more details. |
|
844
930
|
* 可选,屏幕共享配置,如果 videoInputDeviceId 是 'screenShare',请参考 https://www.volcengine.com/docs/6348/104481#screenconfig 了解更多详情。
|
931
|
+
* @param config.prologueContent - Optional, Prologue content. | 可选,开场白内容。
|
932
|
+
* @param config.roomMode - Optional, Room mode. | 可选,房间模式。
|
845
933
|
*/ constructor(config){
|
846
934
|
super(config.debug), this._client = null, this.isConnected = false, this._isTestEnv = false, this._isSupportVideo = false;
|
847
935
|
this._config = config;
|
@@ -12,6 +12,10 @@ var event_names_EventNames = /*#__PURE__*/ function(EventNames) {
|
|
12
12
|
* zh: 所有服务端事件
|
13
13
|
*/ EventNames["ALL_SERVER"] = "server.*";
|
14
14
|
/**
|
15
|
+
* en: Room info
|
16
|
+
* zh: 房间信息
|
17
|
+
*/ EventNames["ROOM_INFO"] = "client.room.info";
|
18
|
+
/**
|
15
19
|
* en: Client connected
|
16
20
|
* zh: 客户端连接
|
17
21
|
*/ EventNames["CONNECTED"] = "client.connected";
|
@@ -44,6 +48,10 @@ var event_names_EventNames = /*#__PURE__*/ function(EventNames) {
|
|
44
48
|
* zh: 客户端视频关闭
|
45
49
|
*/ EventNames["VIDEO_OFF"] = "client.video.off";
|
46
50
|
/**
|
51
|
+
* en: Client video error
|
52
|
+
* zh: 客户端视频(或屏幕共享)错误
|
53
|
+
*/ EventNames["VIDEO_ERROR"] = "client.video.error";
|
54
|
+
/**
|
47
55
|
* en: Client video event
|
48
56
|
* zh: 客户端视频事件
|
49
57
|
*/ EventNames["PLAYER_EVENT"] = "client.video.event";
|
@@ -110,7 +118,51 @@ var event_names_EventNames = /*#__PURE__*/ function(EventNames) {
|
|
110
118
|
/**
|
111
119
|
* en: Session updated
|
112
120
|
* zh: 会话更新
|
113
|
-
*/ EventNames["
|
121
|
+
*/ EventNames["SESSION_UPDATED"] = "server.session.updated";
|
122
|
+
/**
|
123
|
+
* en: Conversation created
|
124
|
+
* zh: 会话创建
|
125
|
+
*/ EventNames["CONVERSATION_CREATED"] = "server.conversation.created";
|
126
|
+
/**
|
127
|
+
* en: Conversation chat created
|
128
|
+
* zh: 会话对话创建
|
129
|
+
*/ EventNames["CONVERSATION_CHAT_CREATED"] = "server.conversation.chat.created";
|
130
|
+
/**
|
131
|
+
* en: Conversation chat in progress
|
132
|
+
* zh: 对话正在处理中
|
133
|
+
*/ EventNames["CONVERSATION_CHAT_IN_PROGRESS"] = "server.conversation.chat.in_progress";
|
134
|
+
/**
|
135
|
+
* en: Conversation message delta received
|
136
|
+
* zh: 文本消息增量返回
|
137
|
+
*/ EventNames["CONVERSATION_MESSAGE_DELTA"] = "server.conversation.message.delta";
|
138
|
+
/**
|
139
|
+
* en: Conversation message completed
|
140
|
+
* zh: 文本消息完成
|
141
|
+
*/ EventNames["CONVERSATION_MESSAGE_COMPLETED"] = "server.conversation.message.completed";
|
142
|
+
/**
|
143
|
+
* en: Conversation chat completed
|
144
|
+
* zh: 对话完成
|
145
|
+
*/ EventNames["CONVERSATION_CHAT_COMPLETED"] = "server.conversation.chat.completed";
|
146
|
+
/**
|
147
|
+
* en: Conversation chat requires action
|
148
|
+
* zh: 对话需要插件
|
149
|
+
*/ EventNames["CONVERSATION_CHAT_REQUIRES_ACTION"] = "server.conversation.chat.requires_action";
|
150
|
+
/**
|
151
|
+
* en: Conversation chat failed
|
152
|
+
* zh: 对话失败
|
153
|
+
*/ EventNames["CONVERSATION_CHAT_FAILED"] = "server.conversation.chat.failed";
|
154
|
+
/**
|
155
|
+
* en: Session pre answer updated
|
156
|
+
* zh: 安抚配置更新成功
|
157
|
+
*/ EventNames["SESSION_PRE_ANSWER_UPDATED"] = "server.session.pre_answer.updated";
|
158
|
+
/**
|
159
|
+
* en: Conversation audio transcript delta
|
160
|
+
* zh: 用户语音识别字幕
|
161
|
+
*/ EventNames["CONVERSATION_AUDIO_TRANSCRIPT_DELTA"] = "server.conversation.audio_transcript.delta";
|
162
|
+
/**
|
163
|
+
* en: Mode updated
|
164
|
+
* zh: 更新房间模式成功
|
165
|
+
*/ EventNames["MODE_UPDATED"] = "server.mode.updated";
|
114
166
|
return EventNames;
|
115
167
|
}(event_names_EventNames || {});
|
116
168
|
/* ESM default export */ const event_names = event_names_EventNames;
|