@ray-js/t-agent-ui-ray 0.1.0-beta-2 → 0.1.0-beta-3

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.
@@ -6,4 +6,5 @@ export default function ChatContainer<T extends ChatAgent<any>>(props: PropsWith
6
6
  createAgent: () => T;
7
7
  renderOptions?: RenderOptions;
8
8
  className?: string;
9
+ agentRef?: React.MutableRefObject<T>;
9
10
  }>): React.JSX.Element;
@@ -29,6 +29,9 @@ export default function ChatContainer(props) {
29
29
  }
30
30
  return agent;
31
31
  });
32
+ if (props.agentRef) {
33
+ props.agentRef.current = agent;
34
+ }
32
35
  const uiAgent = useMemo(() => {
33
36
  const session = {
34
37
  get: agent.session.get,
@@ -8,4 +8,4 @@ export declare const useRenderOptions: () => import("..").RenderOptions;
8
8
  export declare const useOnEvent: (eventName: string, callback: (details: any) => void) => void;
9
9
  export declare const useEmitEvent: () => <T extends keyof import("@ray-js/t-agent").UIEventMap>(eventName: T, detail: import("@ray-js/t-agent").UIEventMap[T]) => void;
10
10
  export declare const useTileProps: () => import("..").TileProps<any, any>;
11
- export declare const useSendAction: () => (tttAction: TTTAction) => void;
11
+ export declare const useSendAction: () => (action: TTTAction) => void;
@@ -32,9 +32,14 @@ export const useSendAction = () => {
32
32
  const {
33
33
  emitTileEvent
34
34
  } = useTileProps();
35
- return useCallback(tttAction => {
35
+ const agent = useChatAgent();
36
+ const tileSendAction = useCallback(tttAction => {
36
37
  emitTileEvent({
37
38
  tttAction
38
39
  });
39
40
  }, [emitTileEvent]);
41
+ const uiSendAction = useCallback(action => {
42
+ agent.plugins.ui.emitEvent('runTTTAction', action);
43
+ }, [agent]);
44
+ return emitTileEvent ? tileSendAction : uiSendAction;
40
45
  };
@@ -4,7 +4,7 @@ import "core-js/modules/esnext.iterator.for-each.js";
4
4
  import "core-js/modules/esnext.iterator.map.js";
5
5
  import "core-js/modules/web.dom-collections.iterator.js";
6
6
  import { useState, useEffect, useCallback } from 'react';
7
- import { getSystemInfoSync, setClipboardData, showModal, showToast, vibrateShort } from '@ray-js/ray';
7
+ import { setClipboardData, showModal, showToast, vibrateShort } from '@ray-js/ray';
8
8
  import logger from '../logger';
9
9
  import { useRenderOptions } from './context';
10
10
  import { useChatAgent } from '.';
@@ -44,7 +44,7 @@ export function useLongPress() {
44
44
  });
45
45
  useEffect(() => {
46
46
  try {
47
- const systemInfo = getSystemInfoSync();
47
+ const systemInfo = ty.getSystemInfoSync();
48
48
  setScreenSize({
49
49
  width: systemInfo.windowWidth,
50
50
  height: systemInfo.windowHeight
@@ -10,7 +10,6 @@ import React, { useEffect, useState, useCallback, memo } from 'react';
10
10
  import { Image } from '@ray-js/ray';
11
11
  import { BubbleTileStatus, ChatMessageStatus, safeParseJSON } from '@ray-js/t-agent';
12
12
  import { getCurrentHomeInfo, submitEvaluation } from '@ray-js/t-agent-plugin-assistant';
13
- import { setStorage, getStorage, showToast } from '@ray-js/api';
14
13
  import TileRender from '../../TileRender';
15
14
  import noticeSvg from './notice.svg';
16
15
  import noticeWarnSvg from './notice-warn.svg';
@@ -43,7 +42,7 @@ const BubbleTile = props => {
43
42
  const [feedbackLoaded, setFeedbackLoaded] = useState(false);
44
43
  const [feedbackValue, setFeedbackValue] = useState(null);
45
44
  useEffect(() => {
46
- getStorage({
45
+ ty.getStorage({
47
46
  key: 'latestMessageFeedbackValue',
48
47
  success: res => {
49
48
  if (res.data) {
@@ -65,7 +64,7 @@ const BubbleTile = props => {
65
64
  }, []);
66
65
  const showInfo = () => {
67
66
  if (data.info) {
68
- showToast({
67
+ ty.showToast({
69
68
  title: data.info,
70
69
  icon: 'none'
71
70
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/t-agent-ui-ray",
3
- "version": "0.1.0-beta-2",
3
+ "version": "0.1.0-beta-3",
4
4
  "author": "Tuya.inc",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -41,5 +41,5 @@
41
41
  "@types/echarts": "^4.9.22",
42
42
  "@types/markdown-it": "^14.1.1"
43
43
  },
44
- "gitHead": "e5fe943c9f582704342687e11f76fa3b9b0802b1"
44
+ "gitHead": "afafdb05637f3c9cb46ef3ef518319baa748199e"
45
45
  }