@ray-js/t-agent-ui-ray 0.2.0-beta-14 → 0.2.0-beta-16
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/MessageInput/MessageInputAIStream/AsrInput.js +9 -2
- package/dist/MessageInput/MessageInputAIStream/index.js +14 -22
- package/dist/tiles/OperateCardTile/Expand.js +1 -1
- package/dist/tiles/OperateCardTile/Expand.less +40 -42
- package/dist/tiles/OperateCardTile/Tabs.less +14 -14
- package/package.json +2 -2
|
@@ -4,6 +4,7 @@ import { Button, View } from '@ray-js/ray';
|
|
|
4
4
|
import cx from 'clsx';
|
|
5
5
|
import { useTranslate } from '../../hooks';
|
|
6
6
|
import { WaveformVisualizer } from './WaveformVisualizer';
|
|
7
|
+
import logger from '../../logger';
|
|
7
8
|
const AsrInput = props => {
|
|
8
9
|
const touchRef = useRef({
|
|
9
10
|
startAt: 0,
|
|
@@ -72,8 +73,14 @@ const AsrInput = props => {
|
|
|
72
73
|
const touchY = touch.pageY;
|
|
73
74
|
setCancel(touchRef.current.y - touchY > 100);
|
|
74
75
|
},
|
|
75
|
-
onTouchCancel:
|
|
76
|
-
|
|
76
|
+
onTouchCancel: event => {
|
|
77
|
+
logger.debug('MessageInputAIStream onTouchCancel');
|
|
78
|
+
onVoiceTouchEnd(event);
|
|
79
|
+
},
|
|
80
|
+
onTouchEnd: event => {
|
|
81
|
+
logger.debug('MessageInputAIStream onTouchEnd');
|
|
82
|
+
onVoiceTouchEnd(event);
|
|
83
|
+
}
|
|
77
84
|
}, /*#__PURE__*/React.createElement(View, {
|
|
78
85
|
className: "t-agent-message-input-ptt-text"
|
|
79
86
|
}, " ", t('t-agent.input.asr.ptt')), /*#__PURE__*/React.createElement(View, {
|
|
@@ -36,20 +36,17 @@ var InputAction = /*#__PURE__*/function (InputAction) {
|
|
|
36
36
|
InputAction["ABORT"] = "abort";
|
|
37
37
|
InputAction["TEXT_END"] = "text_end";
|
|
38
38
|
InputAction["ABORT_DONE"] = "abort_done";
|
|
39
|
-
InputAction["NETWORK_CHANGE"] = "network_change";
|
|
40
39
|
return InputAction;
|
|
41
40
|
}(InputAction || {});
|
|
42
41
|
const transitions = {
|
|
43
42
|
[InputState.PENDING]: {
|
|
44
43
|
[InputAction.SEND]: InputState.RESPONDING,
|
|
45
44
|
[InputAction.RECORD]: InputState.RECORDING,
|
|
46
|
-
[InputAction.NETWORK_CHANGE]: InputState.PENDING,
|
|
47
45
|
// 这个变更是为了兼容 pushInputBlocks 结束的场景,没有实际意义
|
|
48
46
|
[InputAction.TEXT_END]: InputState.PENDING
|
|
49
47
|
},
|
|
50
48
|
[InputState.RECORDING]: {
|
|
51
49
|
[InputAction.RECORD_TIMEOUT]: InputState.ASR,
|
|
52
|
-
[InputAction.NETWORK_CHANGE]: InputState.PENDING,
|
|
53
50
|
[InputAction.RECORD_CANCEL]: InputState.PENDING,
|
|
54
51
|
[InputAction.RECORD_CONFIRM]: InputState.ASR,
|
|
55
52
|
[InputAction.ABORT]: InputState.ABORTING,
|
|
@@ -58,17 +55,14 @@ const transitions = {
|
|
|
58
55
|
[InputState.ASR]: {
|
|
59
56
|
[InputAction.ASR_END]: InputState.RESPONDING,
|
|
60
57
|
[InputAction.ASR_ERROR]: InputState.PENDING,
|
|
61
|
-
[InputAction.ABORT]: InputState.ABORTING
|
|
62
|
-
[InputAction.NETWORK_CHANGE]: InputState.PENDING
|
|
58
|
+
[InputAction.ABORT]: InputState.ABORTING
|
|
63
59
|
},
|
|
64
60
|
[InputState.RESPONDING]: {
|
|
65
61
|
[InputAction.ABORT]: InputState.ABORTING,
|
|
66
|
-
[InputAction.TEXT_END]: InputState.PENDING
|
|
67
|
-
[InputAction.NETWORK_CHANGE]: InputState.PENDING
|
|
62
|
+
[InputAction.TEXT_END]: InputState.PENDING
|
|
68
63
|
},
|
|
69
64
|
[InputState.ABORTING]: {
|
|
70
|
-
[InputAction.ABORT_DONE]: InputState.PENDING
|
|
71
|
-
[InputAction.NETWORK_CHANGE]: InputState.PENDING
|
|
65
|
+
[InputAction.ABORT_DONE]: InputState.PENDING
|
|
72
66
|
}
|
|
73
67
|
};
|
|
74
68
|
export default function MessageInputAIStream(props) {
|
|
@@ -123,14 +117,6 @@ export default function MessageInputAIStream(props) {
|
|
|
123
117
|
const agent = useChatAgent();
|
|
124
118
|
const emitEvent = useEmitEvent();
|
|
125
119
|
const isUnmounted = useIsUnmounted();
|
|
126
|
-
useOnEvent('networkChange', _ref => {
|
|
127
|
-
let {
|
|
128
|
-
online
|
|
129
|
-
} = _ref;
|
|
130
|
-
if (!online) {
|
|
131
|
-
dispatch(InputAction.NETWORK_CHANGE, {});
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
120
|
const hasMore = attachmentOptions.image || attachmentOptions.video;
|
|
135
121
|
const isMore = !text.trim().length && hasMore;
|
|
136
122
|
const send = async inputBlocks => {
|
|
@@ -165,19 +151,19 @@ export default function MessageInputAIStream(props) {
|
|
|
165
151
|
}
|
|
166
152
|
}
|
|
167
153
|
};
|
|
168
|
-
useOnEvent('sendMessage', async
|
|
154
|
+
useOnEvent('sendMessage', async _ref => {
|
|
169
155
|
let {
|
|
170
156
|
blocks
|
|
171
|
-
} =
|
|
157
|
+
} = _ref;
|
|
172
158
|
if (uploading) {
|
|
173
159
|
return;
|
|
174
160
|
}
|
|
175
161
|
send(blocks);
|
|
176
162
|
});
|
|
177
|
-
useOnEvent('setInputBlocks', async
|
|
163
|
+
useOnEvent('setInputBlocks', async _ref2 => {
|
|
178
164
|
let {
|
|
179
165
|
blocks
|
|
180
|
-
} =
|
|
166
|
+
} = _ref2;
|
|
181
167
|
if (uploading || state.current !== InputState.PENDING) {
|
|
182
168
|
return;
|
|
183
169
|
}
|
|
@@ -304,6 +290,12 @@ export default function MessageInputAIStream(props) {
|
|
|
304
290
|
const emitter = new Emitter();
|
|
305
291
|
emitter.addEventListener('error', async error => {
|
|
306
292
|
logger.error('MessageInputAIStream', 'AsrInput error', error);
|
|
293
|
+
if (state.current === InputState.RECORDING) {
|
|
294
|
+
clearTimeout(state.payload.recordTimeOutId);
|
|
295
|
+
}
|
|
296
|
+
if (state.current === InputState.RESPONDING) {
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
307
299
|
if (dispatch(InputAction.ASR_ERROR, {})) {
|
|
308
300
|
var _error$detail;
|
|
309
301
|
if (((_error$detail = error.detail) === null || _error$detail === void 0 ? void 0 : _error$detail.name) === 'AsrEmptyError') {
|
|
@@ -382,7 +374,7 @@ export default function MessageInputAIStream(props) {
|
|
|
382
374
|
onConfirm: async () => {
|
|
383
375
|
logger.debug('MessageInputAIStream', 'AsrInput onConfirm');
|
|
384
376
|
recordingFlagRef.current = false;
|
|
385
|
-
if (state.current === InputState.ABORTING) {
|
|
377
|
+
if (state.current === InputState.ABORTING || state.current === InputState.PENDING) {
|
|
386
378
|
return;
|
|
387
379
|
}
|
|
388
380
|
const payload = state.payload;
|
|
@@ -67,7 +67,7 @@ export default function Expand(_ref) {
|
|
|
67
67
|
className: "t-agent-expand-device-room"
|
|
68
68
|
}, "-", device.room)), /*#__PURE__*/React.createElement(Text, {
|
|
69
69
|
className: "t-agent-expand-device-status"
|
|
70
|
-
}, device.success ? t('t-agent.expand.execution.success') : t('t-agent.expand.execution.failed'))));
|
|
70
|
+
}, device.success == null ? '' : device.success ? t('t-agent.expand.execution.success') : t('t-agent.expand.execution.failed'))));
|
|
71
71
|
}), (_operations$moreDevic2 = operations.moreDevice) === null || _operations$moreDevic2 === void 0 ? void 0 : _operations$moreDevic2.map(device => /*#__PURE__*/React.createElement(View, {
|
|
72
72
|
key: device.id,
|
|
73
73
|
className: "t-agent-expand-device-item",
|
|
@@ -1,33 +1,31 @@
|
|
|
1
1
|
.t-agent-expand {
|
|
2
2
|
&-container {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
7
|
-
margin-top: 12px;
|
|
3
|
+
background-color: var(--app-B3);
|
|
4
|
+
border-radius: 16rpx;
|
|
5
|
+
margin-top: 16rpx;
|
|
8
6
|
}
|
|
9
7
|
|
|
10
8
|
&-empty {
|
|
11
9
|
display: flex;
|
|
12
10
|
justify-content: center;
|
|
13
11
|
align-items: center;
|
|
14
|
-
min-height:
|
|
15
|
-
color:
|
|
12
|
+
min-height: 200rpx;
|
|
13
|
+
color: var(--app-B1-N3);
|
|
16
14
|
}
|
|
17
15
|
|
|
18
16
|
&-device {
|
|
19
17
|
&-list {
|
|
20
18
|
display: flex;
|
|
21
19
|
flex-direction: column;
|
|
22
|
-
gap:
|
|
20
|
+
gap: 24rpx;
|
|
23
21
|
}
|
|
24
22
|
|
|
25
23
|
&-item {
|
|
26
24
|
display: flex;
|
|
27
25
|
align-items: center;
|
|
28
|
-
padding:
|
|
29
|
-
background-color:
|
|
30
|
-
border-radius:
|
|
26
|
+
padding: 12rpx;
|
|
27
|
+
background-color: var(--app-B1);
|
|
28
|
+
border-radius: 12rpx;
|
|
31
29
|
|
|
32
30
|
&:active {
|
|
33
31
|
opacity: 0.8;
|
|
@@ -35,10 +33,10 @@
|
|
|
35
33
|
}
|
|
36
34
|
|
|
37
35
|
&-icon {
|
|
38
|
-
width:
|
|
39
|
-
height:
|
|
40
|
-
border-radius:
|
|
41
|
-
margin-right:
|
|
36
|
+
width: 80rpx;
|
|
37
|
+
height: 80rpx;
|
|
38
|
+
border-radius: 24rpx;
|
|
39
|
+
margin-right: 10rpx;
|
|
42
40
|
}
|
|
43
41
|
|
|
44
42
|
&-info {
|
|
@@ -47,20 +45,20 @@
|
|
|
47
45
|
}
|
|
48
46
|
|
|
49
47
|
&-name {
|
|
50
|
-
font-size:
|
|
48
|
+
font-size: 24rpx;
|
|
51
49
|
font-weight: 500;
|
|
52
|
-
color:
|
|
50
|
+
color: var(--app-B1-N1);
|
|
53
51
|
}
|
|
54
52
|
|
|
55
53
|
&-room {
|
|
56
|
-
font-size:
|
|
57
|
-
color:
|
|
58
|
-
margin-left:
|
|
54
|
+
font-size: 24rpx;
|
|
55
|
+
color: var(--app-B1-N3);
|
|
56
|
+
margin-left: 8rpx;
|
|
59
57
|
}
|
|
60
58
|
|
|
61
59
|
&-status {
|
|
62
|
-
font-size:
|
|
63
|
-
color:
|
|
60
|
+
font-size: 24rpx;
|
|
61
|
+
color: var(--app-B1-N1);
|
|
64
62
|
}
|
|
65
63
|
}
|
|
66
64
|
|
|
@@ -68,15 +66,15 @@
|
|
|
68
66
|
&-list {
|
|
69
67
|
display: flex;
|
|
70
68
|
flex-direction: column;
|
|
71
|
-
gap:
|
|
69
|
+
gap: 24rpx;
|
|
72
70
|
}
|
|
73
71
|
|
|
74
72
|
&-item {
|
|
75
73
|
display: flex;
|
|
76
74
|
align-items: center;
|
|
77
|
-
padding:
|
|
78
|
-
background-color:
|
|
79
|
-
border-radius:
|
|
75
|
+
padding: 24rpx;
|
|
76
|
+
background-color: var(--app-B1);
|
|
77
|
+
border-radius: 12rpx;
|
|
80
78
|
|
|
81
79
|
&:active {
|
|
82
80
|
opacity: 0.8;
|
|
@@ -84,21 +82,21 @@
|
|
|
84
82
|
}
|
|
85
83
|
|
|
86
84
|
&-icon {
|
|
87
|
-
width:
|
|
88
|
-
height:
|
|
89
|
-
border-radius:
|
|
90
|
-
margin-right:
|
|
85
|
+
width: 80rpx;
|
|
86
|
+
height: 80rpx;
|
|
87
|
+
border-radius: 24rpx;
|
|
88
|
+
margin-right: 10rpx;
|
|
91
89
|
}
|
|
92
90
|
|
|
93
91
|
&-name {
|
|
94
|
-
font-size:
|
|
92
|
+
font-size: 28rpx;
|
|
95
93
|
font-weight: 500;
|
|
96
|
-
color:
|
|
94
|
+
color: var(--app-B1-N1);
|
|
97
95
|
}
|
|
98
96
|
|
|
99
97
|
&-status {
|
|
100
|
-
font-size:
|
|
101
|
-
color:
|
|
98
|
+
font-size: 24rpx;
|
|
99
|
+
color: var(--app-B1-N1);
|
|
102
100
|
}
|
|
103
101
|
}
|
|
104
102
|
|
|
@@ -106,15 +104,15 @@
|
|
|
106
104
|
&-list {
|
|
107
105
|
display: flex;
|
|
108
106
|
flex-direction: column;
|
|
109
|
-
gap:
|
|
107
|
+
gap: 24rpx;
|
|
110
108
|
}
|
|
111
109
|
|
|
112
110
|
&-item {
|
|
113
111
|
display: flex;
|
|
114
112
|
align-items: center;
|
|
115
|
-
padding:
|
|
116
|
-
background-color:
|
|
117
|
-
border-radius:
|
|
113
|
+
padding: 24rpx;
|
|
114
|
+
background-color: var(--app-B1);
|
|
115
|
+
border-radius: 12rpx;
|
|
118
116
|
|
|
119
117
|
&:active {
|
|
120
118
|
opacity: 0.8;
|
|
@@ -122,14 +120,14 @@
|
|
|
122
120
|
}
|
|
123
121
|
|
|
124
122
|
&-name {
|
|
125
|
-
font-size:
|
|
123
|
+
font-size: 28rpx;
|
|
126
124
|
font-weight: 500;
|
|
127
|
-
color:
|
|
125
|
+
color: var(--app-B1-N1);
|
|
128
126
|
}
|
|
129
127
|
|
|
130
128
|
&-status {
|
|
131
|
-
font-size:
|
|
132
|
-
color:
|
|
129
|
+
font-size: 24rpx;
|
|
130
|
+
color: var(--app-B1-N3);
|
|
133
131
|
}
|
|
134
132
|
}
|
|
135
133
|
}
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
|
|
4
4
|
&-header {
|
|
5
5
|
display: flex;
|
|
6
|
-
border-bottom:
|
|
7
|
-
margin-bottom:
|
|
6
|
+
border-bottom: 1rpx solid #e6e6e6;
|
|
7
|
+
margin-bottom: 16rpx;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
&-tab {
|
|
11
11
|
position: relative;
|
|
12
|
-
padding:
|
|
13
|
-
margin-right:
|
|
12
|
+
padding: 12rpx 16rpx;
|
|
13
|
+
margin-right: 8rpx;
|
|
14
14
|
cursor: pointer;
|
|
15
15
|
transition: all 0.3s;
|
|
16
16
|
|
|
@@ -28,27 +28,27 @@
|
|
|
28
28
|
bottom: 0;
|
|
29
29
|
left: 0;
|
|
30
30
|
width: 100%;
|
|
31
|
-
height:
|
|
31
|
+
height: 4rpx;
|
|
32
32
|
background-color: #0089ff;
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
&-title {
|
|
37
|
-
font-size:
|
|
37
|
+
font-size: 28rpx;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
&-badge {
|
|
41
41
|
position: absolute;
|
|
42
|
-
top:
|
|
43
|
-
right:
|
|
44
|
-
min-width:
|
|
45
|
-
height:
|
|
46
|
-
padding: 0
|
|
42
|
+
top: -8rpx;
|
|
43
|
+
right: -8rpx;
|
|
44
|
+
min-width: 32rpx;
|
|
45
|
+
height: 32rpx;
|
|
46
|
+
padding: 0 8rpx;
|
|
47
47
|
background-color: #ff4d4f;
|
|
48
|
-
border-radius:
|
|
48
|
+
border-radius: 16rpx;
|
|
49
49
|
color: #fff;
|
|
50
|
-
font-size:
|
|
51
|
-
line-height:
|
|
50
|
+
font-size: 24rpx;
|
|
51
|
+
line-height: 32rpx;
|
|
52
52
|
text-align: center;
|
|
53
53
|
}
|
|
54
54
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ray-js/t-agent-ui-ray",
|
|
3
|
-
"version": "0.2.0-beta-
|
|
3
|
+
"version": "0.2.0-beta-16",
|
|
4
4
|
"author": "Tuya.inc",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"@types/echarts": "^4.9.22",
|
|
41
41
|
"@types/markdown-it": "^14.1.1"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "d9abc8e193dc1db6a7f9fca9ebeba2ff6462b713"
|
|
44
44
|
}
|