@ray-js/t-agent-ui-ray 0.2.8-beta.1 → 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.
@@ -1,3 +1,4 @@
1
+ /* istanbul ignore file */
1
2
  import './index.less';
2
3
  import { View } from '@ray-js/components';
3
4
  import React from 'react';
@@ -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 new Promise(resolve => {
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');
@@ -1,3 +1,4 @@
1
+ /* istanbul ignore file */
1
2
  import MessageInputAIStream, { MessageInputState } from './MessageInputAIStream';
2
3
  export { MessageInputState };
3
4
  export default MessageInputAIStream;
@@ -10,8 +10,8 @@ interface ScrollBottomViewOptions {
10
10
  }
11
11
  export declare function useScrollBottomView(options: ScrollBottomViewOptions): {
12
12
  scrollToBottom: ({ animation, follow }: {
13
- animation?: boolean | undefined;
14
- follow?: boolean | undefined;
13
+ animation?: boolean;
14
+ follow?: boolean;
15
15
  }) => Promise<boolean>;
16
16
  scrollViewLoading: boolean;
17
17
  scrollIntoViewId: string;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ChatAgent, ChatMessageObject, UIPlugin } from '@ray-js/t-agent';
3
2
  import { RenderOptions, TileProps } from './types';
4
3
  import { ChatSession } from '@ray-js/t-agent';
@@ -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: 'image' | 'video' | 'camera' | 'album', count?: any) => Promise<void>;
20
+ upload: (type: "image" | "video" | "camera" | "album", count?: any) => Promise<void>;
22
21
  };
@@ -1,3 +1,4 @@
1
+ /* istanbul ignore file */
1
2
  export default {
2
3
  'zh-Hans': {
3
4
  't-agent.build-in.button.create_scene_manually': '手动创建场景',
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ /* istanbul ignore file */
1
2
  import ChatContainer from './ChatContainer';
2
3
  import MessageInput from './MessageInput';
3
4
  import MessageList from './MessageList';
@@ -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: (message, code) => {
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, any>) => React.JSX.Element>;
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, any>) => React.JSX.Element | null>;
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, any>) => React.JSX.Element>;
7
+ declare const _default: React.MemoExoticComponent<(props: TileProps<DividerTileData>) => React.JSX.Element>;
8
8
  export default _default;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import './Expand.less';
3
3
  export declare enum SceneType {
4
- EXECUTE = 1,
4
+ EXECUTE = 1,// 一键执行
5
5
  AUTO = 2
6
6
  }
7
7
  type DeviceInfoItem = any;
@@ -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, any>) => React.JSX.Element>;
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, any>) => React.JSX.Element>;
5
+ declare const _default: React.MemoExoticComponent<(props: TileProps<TipTileData>) => React.JSX.Element>;
6
6
  export default _default;
@@ -1,5 +1,5 @@
1
1
  export declare enum SceneType {
2
- EXECUTE = 1,
2
+ EXECUTE = 1,// 一键执行
3
3
  AUTO = 2
4
4
  }
5
5
  export interface SceneInfoItem {
@@ -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 }: React.PropsWithChildren<{
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], <K_1 extends keyof T>(key: K_1) => [T[K_1], (v: T[K_1]) => void]];
4
+ }>) => React.JSX.Element, <K extends keyof T>(key: K) => T[K], <K extends keyof T>(key: K) => [T[K], (v: T[K]) => void]];
@@ -1,3 +1,4 @@
1
+ /* istanbul ignore file */
1
2
  export function routeScene(sceneId) {
2
3
  ty.router({
3
4
  url: "thingSmart://editScene?sceneId=".concat(sceneId, "&biz_type=ai_smart&action=edit"),
@@ -96,3 +96,4 @@ export declare const getCurrentHomeInfo: () => Promise<{
96
96
  homeId: string;
97
97
  homeName: string;
98
98
  }>;
99
+ export declare const initAudioRecorder: () => Promise<void>;
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.8-beta.1",
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": "040499ca11aedda3246121f880807da0f8af3cc9"
45
+ "gitHead": "450ca8d41536094b3bea57198fd7724ba6812438"
44
46
  }