@ray-js/t-agent-ui-ray 0.2.7 → 0.2.8-beta.2
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/LowCodeCardRender/index.js +1 -0
- package/dist/MessageInput/MessageInputAIStream/index.js +2 -24
- package/dist/MessageInput/index.js +1 -0
- package/dist/MessageList/ScrollBottomView.d.ts +2 -2
- package/dist/contexts.d.ts +0 -1
- package/dist/hooks/context.d.ts +1 -1
- package/dist/hooks/useAttachmentInput.d.ts +1 -2
- package/dist/i18n/strings.js +1 -0
- package/dist/index.js +1 -0
- package/dist/renderOption.js +7 -6
- package/dist/tiles/BubbleTile/index.d.ts +1 -1
- package/dist/tiles/CardTile/index.d.ts +1 -1
- package/dist/tiles/DividerTile/index.d.ts +1 -1
- package/dist/tiles/OperateCardTile/Expand.d.ts +1 -1
- package/dist/tiles/TextTile/index.d.ts +1 -1
- package/dist/tiles/TipTile/index.d.ts +1 -1
- package/dist/tiles/types.d.ts +1 -1
- package/dist/utils/abort.js +1 -0
- package/dist/utils/createSharedStore.d.ts +2 -2
- package/dist/utils/index.js +1 -0
- package/dist/utils/ttt.d.ts +1 -0
- package/dist/utils/ttt.js +24 -0
- package/package.json +5 -3
|
@@ -16,10 +16,9 @@ import cameraSvg from '../icons/camera.svg';
|
|
|
16
16
|
import { useAttachmentInput, useChatAgent, useEmitEvent, useIsUnmounted, useOnEvent, useTranslate } from '../../hooks';
|
|
17
17
|
import AsrInput from './AsrInput';
|
|
18
18
|
import logger from '../../logger';
|
|
19
|
-
import { systemInfo } from '../../utils';
|
|
20
19
|
import { useSleep } from '../../hooks/useSleep';
|
|
21
20
|
import { useStableCallback } from '../../hooks/useStableCallback';
|
|
22
|
-
import { authorize } from '../../utils/ttt';
|
|
21
|
+
import { authorize, initAudioRecorder } from '../../utils/ttt';
|
|
23
22
|
export let MessageInputState = /*#__PURE__*/function (MessageInputState) {
|
|
24
23
|
MessageInputState["PENDING"] = "pending";
|
|
25
24
|
MessageInputState["RECORDING"] = "recording";
|
|
@@ -258,28 +257,7 @@ export default function MessageInputAIStream(props) {
|
|
|
258
257
|
}
|
|
259
258
|
if (!initAudioRef.current) {
|
|
260
259
|
initAudioRef.current = true;
|
|
261
|
-
await
|
|
262
|
-
if (!ty.aistream.initAudioRecorder || systemInfo.brand === 'devtools') {
|
|
263
|
-
resolve();
|
|
264
|
-
return;
|
|
265
|
-
}
|
|
266
|
-
try {
|
|
267
|
-
logger.debug('MessageInputAIStream', 'initAudioRecorder');
|
|
268
|
-
ty.aistream.initAudioRecorder({
|
|
269
|
-
success: () => {
|
|
270
|
-
logger.debug('MessageInputAIStream', 'initAudioRecorder success');
|
|
271
|
-
resolve();
|
|
272
|
-
},
|
|
273
|
-
fail: error => {
|
|
274
|
-
logger.error('MessageInputAIStream', 'initAudioRecorder error', error);
|
|
275
|
-
resolve();
|
|
276
|
-
}
|
|
277
|
-
});
|
|
278
|
-
} catch (error) {
|
|
279
|
-
logger.error('MessageInputAIStream', 'initAudioRecorder error', error);
|
|
280
|
-
resolve();
|
|
281
|
-
}
|
|
282
|
-
});
|
|
260
|
+
await initAudioRecorder();
|
|
283
261
|
}
|
|
284
262
|
setText('');
|
|
285
263
|
setMode('voice');
|
|
@@ -10,8 +10,8 @@ interface ScrollBottomViewOptions {
|
|
|
10
10
|
}
|
|
11
11
|
export declare function useScrollBottomView(options: ScrollBottomViewOptions): {
|
|
12
12
|
scrollToBottom: ({ animation, follow }: {
|
|
13
|
-
animation?: boolean
|
|
14
|
-
follow?: boolean
|
|
13
|
+
animation?: boolean;
|
|
14
|
+
follow?: boolean;
|
|
15
15
|
}) => Promise<boolean>;
|
|
16
16
|
scrollViewLoading: boolean;
|
|
17
17
|
scrollIntoViewId: string;
|
package/dist/contexts.d.ts
CHANGED
package/dist/hooks/context.d.ts
CHANGED
|
@@ -7,5 +7,5 @@ export declare const useKeyboardHeight: () => number;
|
|
|
7
7
|
export declare const useOnEvent: (eventName: string, callback: (details: any) => void) => void;
|
|
8
8
|
export declare const useEmitEvent: () => <T extends keyof import("@ray-js/t-agent").UIEventMap>(eventName: T, detail: import("@ray-js/t-agent").UIEventMap[T]) => void;
|
|
9
9
|
export declare const useTileProps: () => import("../types").TileProps<any, any>;
|
|
10
|
-
export declare const useSendAction: () => (action: TTTAction) => void;
|
|
10
|
+
export declare const useSendAction: () => ((action: TTTAction) => void);
|
|
11
11
|
export declare const useAgentSessionValue: <S = any>(key: string) => readonly [S, Dispatch<SetStateAction<S>>];
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { InputBlock } from '@ray-js/t-agent';
|
|
3
2
|
export type UploadFile = {
|
|
4
3
|
id: string;
|
|
@@ -18,5 +17,5 @@ export declare function useAttachmentInput({ local }?: {
|
|
|
18
17
|
setUploaded: import("react").Dispatch<import("react").SetStateAction<UploadFile[]>>;
|
|
19
18
|
uploading: boolean;
|
|
20
19
|
loadBlocks: (blocks: InputBlock[], append?: boolean) => void;
|
|
21
|
-
upload: (type:
|
|
20
|
+
upload: (type: "image" | "video" | "camera" | "album", count?: any) => Promise<void>;
|
|
22
21
|
};
|
package/dist/i18n/strings.js
CHANGED
package/dist/index.js
CHANGED
package/dist/renderOption.js
CHANGED
|
@@ -72,13 +72,14 @@ const defaultRenderLongPressAs = res => {
|
|
|
72
72
|
return /*#__PURE__*/React.createElement(LongPressActionMenu, res.menuProps);
|
|
73
73
|
};
|
|
74
74
|
const i18nTranslate = key => I18n.t(key);
|
|
75
|
+
const formatErrorMessageAs = (message, code) => {
|
|
76
|
+
if (code) {
|
|
77
|
+
return translateWith("t-agent.error.".concat(code), i18nTranslate);
|
|
78
|
+
}
|
|
79
|
+
return message;
|
|
80
|
+
};
|
|
75
81
|
export const defaultRenderOptions = {
|
|
76
|
-
formatErrorMessageAs
|
|
77
|
-
if (code) {
|
|
78
|
-
return translateWith("t-agent.error.".concat(code), i18nTranslate);
|
|
79
|
-
}
|
|
80
|
-
return message;
|
|
81
|
-
},
|
|
82
|
+
formatErrorMessageAs,
|
|
82
83
|
renderTileAs: defaultChatTileAs,
|
|
83
84
|
renderCustomBlockAs: defaultRenderCustomBlockAs,
|
|
84
85
|
customBlockTypes: defaultCustomBlockTypes,
|
|
@@ -2,5 +2,5 @@ import './index.less';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { BubbleTileData } from '@ray-js/t-agent';
|
|
4
4
|
import { TileProps } from '../../types';
|
|
5
|
-
declare const _default: React.MemoExoticComponent<(props: TileProps<BubbleTileData
|
|
5
|
+
declare const _default: React.MemoExoticComponent<(props: TileProps<BubbleTileData>) => React.JSX.Element>;
|
|
6
6
|
export default _default;
|
|
@@ -2,5 +2,5 @@ import React from 'react';
|
|
|
2
2
|
import './index.less';
|
|
3
3
|
import { CardTileData } from '@ray-js/t-agent';
|
|
4
4
|
import { TileProps } from '../../types';
|
|
5
|
-
declare const _default: React.MemoExoticComponent<(props: TileProps<CardTileData
|
|
5
|
+
declare const _default: React.MemoExoticComponent<(props: TileProps<CardTileData>) => React.JSX.Element | null>;
|
|
6
6
|
export default _default;
|
|
@@ -4,5 +4,5 @@ import { TileProps } from '../../types';
|
|
|
4
4
|
interface DividerTileData {
|
|
5
5
|
text?: string;
|
|
6
6
|
}
|
|
7
|
-
declare const _default: React.MemoExoticComponent<(props: TileProps<DividerTileData
|
|
7
|
+
declare const _default: React.MemoExoticComponent<(props: TileProps<DividerTileData>) => React.JSX.Element>;
|
|
8
8
|
export default _default;
|
|
@@ -5,5 +5,5 @@ interface TileData {
|
|
|
5
5
|
text: string;
|
|
6
6
|
markdown?: boolean;
|
|
7
7
|
}
|
|
8
|
-
declare const _default: React.MemoExoticComponent<(props: TileProps<TileData
|
|
8
|
+
declare const _default: React.MemoExoticComponent<(props: TileProps<TileData>) => React.JSX.Element>;
|
|
9
9
|
export default _default;
|
|
@@ -2,5 +2,5 @@ import React from 'react';
|
|
|
2
2
|
import './index.less';
|
|
3
3
|
import { TipTileData } from '@ray-js/t-agent';
|
|
4
4
|
import { TileProps } from '../../types';
|
|
5
|
-
declare const _default: React.MemoExoticComponent<(props: TileProps<TipTileData
|
|
5
|
+
declare const _default: React.MemoExoticComponent<(props: TileProps<TipTileData>) => React.JSX.Element>;
|
|
6
6
|
export default _default;
|
package/dist/tiles/types.d.ts
CHANGED
package/dist/utils/abort.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import "core-js/modules/es.symbol.description.js";
|
|
2
2
|
import "core-js/modules/web.dom-collections.iterator.js";
|
|
3
|
+
/* istanbul ignore file */
|
|
3
4
|
// source: https://github.com/mo/abortcontroller-polyfill
|
|
4
5
|
import { Emitter } from '@ray-js/t-agent';
|
|
5
6
|
function createAbortEvent(reason) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React, { PropsWithChildren } from 'react';
|
|
2
|
-
export declare function createSharedStore<T>(): readonly [({ value, children }:
|
|
2
|
+
export declare function createSharedStore<T>(): readonly [({ value, children }: PropsWithChildren<{
|
|
3
3
|
value: T;
|
|
4
|
-
}>) => React.JSX.Element, <K extends keyof T>(key: K) => T[K], <
|
|
4
|
+
}>) => React.JSX.Element, <K extends keyof T>(key: K) => T[K], <K extends keyof T>(key: K) => [T[K], (v: T[K]) => void]];
|
package/dist/utils/index.js
CHANGED
package/dist/utils/ttt.d.ts
CHANGED
package/dist/utils/ttt.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
/* istanbul ignore file */
|
|
3
|
+
import logger from '../logger';
|
|
2
4
|
export const authorize = _ref => {
|
|
3
5
|
let {
|
|
4
6
|
scope
|
|
@@ -51,4 +53,26 @@ export const getCurrentHomeInfo = () => {
|
|
|
51
53
|
}
|
|
52
54
|
});
|
|
53
55
|
});
|
|
56
|
+
};
|
|
57
|
+
export const initAudioRecorder = () => {
|
|
58
|
+
return new Promise(resolve => {
|
|
59
|
+
if (!ty.aistream.initAudioRecorder) {
|
|
60
|
+
resolve();
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
try {
|
|
64
|
+
ty.aistream.initAudioRecorder({
|
|
65
|
+
success: () => {
|
|
66
|
+
resolve();
|
|
67
|
+
},
|
|
68
|
+
fail: error => {
|
|
69
|
+
logger.error('MessageInputAIStream', 'initAudioRecorder error', error);
|
|
70
|
+
resolve();
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
} catch (error) {
|
|
74
|
+
logger.error('MessageInputAIStream', 'initAudioRecorder error', error);
|
|
75
|
+
resolve();
|
|
76
|
+
}
|
|
77
|
+
});
|
|
54
78
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ray-js/t-agent-ui-ray",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.8-beta.2",
|
|
4
4
|
"author": "Tuya.inc",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
@@ -21,7 +21,9 @@
|
|
|
21
21
|
"scripts": {
|
|
22
22
|
"dev": "ray start --type=component --output dist --emit-declaration-dev",
|
|
23
23
|
"build": "ray build --type=component --output dist",
|
|
24
|
-
"clean": "rimraf ./dist"
|
|
24
|
+
"clean": "rimraf ./dist",
|
|
25
|
+
"test": "jest --runInBand",
|
|
26
|
+
"test:coverage": "jest --runInBand --coverage"
|
|
25
27
|
},
|
|
26
28
|
"dependencies": {
|
|
27
29
|
"clsx": "^1.2.1",
|
|
@@ -40,5 +42,5 @@
|
|
|
40
42
|
"@types/echarts": "^4.9.22",
|
|
41
43
|
"@types/markdown-it": "^14.1.1"
|
|
42
44
|
},
|
|
43
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "450ca8d41536094b3bea57198fd7724ba6812438"
|
|
44
46
|
}
|