@ray-js/t-agent-ui-ray 0.2.2-beta-1 → 0.2.3-beta-1

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.
Files changed (51) hide show
  1. package/dist/ChatContainer/index.js +1 -9
  2. package/dist/EchartsBlockRender/index.js +8 -10
  3. package/dist/LazyScrollView/LazyItem/index.d.ts +18 -0
  4. package/dist/LazyScrollView/LazyItem/index.js +51 -0
  5. package/dist/LazyScrollView/LazyItem/index.json +3 -0
  6. package/dist/LazyScrollView/LazyItem/index.tyml +16 -0
  7. package/dist/LazyScrollView/index.d.ts +26 -0
  8. package/dist/LazyScrollView/index.js +27 -0
  9. package/dist/LazyScrollView/index.json +3 -0
  10. package/dist/LazyScrollView/index.tyml +15 -0
  11. package/dist/LazyScrollView/lazy-scroll-view.sjs +317 -0
  12. package/dist/LazyScrollView/weak-ref.sjs +45 -0
  13. package/dist/MessageInput/MessageInputAIStream/AsrInput.js +2 -2
  14. package/dist/MessageInput/MessageInputAIStream/Waveform/index.d.ts +9 -0
  15. package/dist/MessageInput/MessageInputAIStream/Waveform/index.js +52 -0
  16. package/dist/MessageInput/MessageInputAIStream/Waveform/index.json +3 -0
  17. package/dist/MessageInput/MessageInputAIStream/Waveform/index.tyml +9 -0
  18. package/dist/MessageInput/MessageInputAIStream/index.d.ts +1 -0
  19. package/dist/MessageInput/MessageInputAIStream/index.js +2 -4
  20. package/dist/MessageList/ScrollBottomView.d.ts +21 -20
  21. package/dist/MessageList/ScrollBottomView.js +59 -135
  22. package/dist/MessageList/index.d.ts +6 -8
  23. package/dist/MessageList/index.js +91 -11
  24. package/dist/MessageList/index.less +1 -2
  25. package/dist/MessageRender/index.d.ts +6 -1
  26. package/dist/MessageRender/index.js +49 -17
  27. package/dist/MessageRender/index.less +5 -3
  28. package/dist/TileRender/index.d.ts +2 -1
  29. package/dist/TileRender/index.js +3 -3
  30. package/dist/contexts.d.ts +1 -5
  31. package/dist/hooks/context.d.ts +0 -2
  32. package/dist/hooks/context.js +0 -6
  33. package/dist/tiles/BubbleTile/index.js +2 -1
  34. package/dist/tiles/CardTile/index.less +1 -1
  35. package/dist/tiles/ExecuteCardTile/index.d.ts +1 -8
  36. package/dist/tiles/ExecuteCardTile/index.js +8 -15
  37. package/dist/tiles/ExecuteCardTile/index.less +177 -151
  38. package/dist/tiles/OperateCardTile/Expand.d.ts +2 -1
  39. package/dist/tiles/OperateCardTile/Expand.js +4 -2
  40. package/dist/tiles/OperateCardTile/index.d.ts +2 -6
  41. package/dist/tiles/OperateCardTile/index.js +6 -9
  42. package/dist/tiles/types.d.ts +31 -0
  43. package/dist/tiles/types.js +5 -0
  44. package/dist/utils/index.js +1 -1
  45. package/dist/utils/object.d.ts +8 -0
  46. package/dist/utils/object.js +57 -0
  47. package/package.json +2 -2
  48. package/dist/MessageInput/MessageInputAIStream/WaveformVisualizer.d.ts +0 -4
  49. package/dist/MessageInput/MessageInputAIStream/WaveformVisualizer.js +0 -54
  50. package/dist/MessageList/LazyView.d.ts +0 -9
  51. package/dist/MessageList/LazyView.js +0 -57
@@ -2,16 +2,13 @@ import React from 'react';
2
2
  import './index.less';
3
3
  import { TileProps } from '../../types';
4
4
  import { IOperations } from './Expand';
5
- type DeviceInfoItem = any;
6
- type SceneInfoItem = any;
7
- type ChangeInfoItem = any;
5
+ import { ChangeInfoItem, DeviceInfoItem, SceneInfoItem } from '../types';
8
6
  export interface OperateCardTileData {
9
7
  deviceInfo: DeviceInfoItem[];
10
8
  sceneInfo: SceneInfoItem[];
11
9
  changeInfo: ChangeInfoItem[];
12
10
  }
13
- export interface OperateCardTileProps extends TileProps {
14
- data: OperateCardTileData;
11
+ export interface OperateCardTileProps extends TileProps<OperateCardTileData> {
15
12
  /** 自定义详情内容渲染函数 */
16
13
  renderDetail?: (props: {
17
14
  operations: IOperations;
@@ -21,4 +18,3 @@ export interface OperateCardTileProps extends TileProps {
21
18
  }) => React.ReactNode;
22
19
  }
23
20
  export default function OperateCardTile(props: OperateCardTileProps): React.JSX.Element | null;
24
- export {};
@@ -5,9 +5,7 @@ import "core-js/modules/web.dom-collections.iterator.js";
5
5
  import { Text, View } from '@ray-js/components';
6
6
  import React, { useMemo, useState } from 'react';
7
7
  import './index.less';
8
- // import { ChangeInfoItem, DeviceInfoItem, SceneInfoItem } from '@ray-js/t-agent-plugin-assistant';
9
-
10
- import { useTileProps, useTranslate } from '../../hooks';
8
+ import { useTranslate } from '../../hooks';
11
9
  import Expand from './Expand';
12
10
  import { formatMessage } from '../../utils';
13
11
  const handleDesc = (detail, t) => {
@@ -76,7 +74,8 @@ const handleDesc = (detail, t) => {
76
74
  export default function OperateCardTile(props) {
77
75
  const {
78
76
  tile,
79
- renderDetail
77
+ renderDetail,
78
+ notifyHeightChanged
80
79
  } = props;
81
80
  const {
82
81
  deviceInfo = [],
@@ -100,7 +99,7 @@ export default function OperateCardTile(props) {
100
99
  const tapScene = e => {
101
100
  const sceneId = e.currentTarget.dataset.id;
102
101
  ty.router({
103
- url: "tuyaSmart://editScene?sceneId=".concat(sceneId, "&biz_type=ai_smart&action=edit"),
102
+ url: "thingSmart://editScene?sceneId=".concat(sceneId, "&biz_type=ai_smart&action=edit"),
104
103
  fail: () => {
105
104
  ty.showToast({
106
105
  title: t('t-agent.operate-card-tile.open.scene.failed'),
@@ -197,9 +196,6 @@ export default function OperateCardTile(props) {
197
196
  };
198
197
  }, [deviceInfo, sceneInfo, changeInfo, t]);
199
198
  const desc = useMemo(() => handleDesc(operations, t), [operations, t]);
200
- const {
201
- notifyHeightChanged
202
- } = useTileProps();
203
199
  if (!operations.device.length && !operations.scene.length && !operations.moreDevice.length && !operations.moreScene.length) {
204
200
  return null;
205
201
  }
@@ -221,6 +217,7 @@ export default function OperateCardTile(props) {
221
217
  }), showDetail && !renderDetail && /*#__PURE__*/React.createElement(Expand, {
222
218
  operations: operations,
223
219
  tapDevice: tapDevice,
224
- tapScene: tapScene
220
+ tapScene: tapScene,
221
+ onChangeTab: () => notifyHeightChanged()
225
222
  }));
226
223
  }
@@ -0,0 +1,31 @@
1
+ export declare enum SceneType {
2
+ EXECUTE = 1,
3
+ AUTO = 2
4
+ }
5
+ export interface SceneInfoItem {
6
+ success: boolean;
7
+ icon: string;
8
+ name: string;
9
+ sceneId: string;
10
+ displayColor: string;
11
+ type: SceneType;
12
+ intent: 'queryScene' | 'controlScene' | 'createScene' | 'deleteScene' | 'updateScene';
13
+ enabled: boolean;
14
+ valid: boolean;
15
+ }
16
+ export interface DeviceInfoItem {
17
+ success: boolean;
18
+ icon: string;
19
+ name: string;
20
+ deviceId: string;
21
+ intent: 'queryDevice' | 'controlDevice' | 'shareDevice';
22
+ room?: string;
23
+ }
24
+ export interface ChangeInfoItem {
25
+ id: string;
26
+ type: 'room' | 'device' | 'scene' | 'group' | 'home' | 'deviceRoom';
27
+ fromData: string;
28
+ toData: string;
29
+ success: boolean;
30
+ desc: string;
31
+ }
@@ -0,0 +1,5 @@
1
+ export let SceneType = /*#__PURE__*/function (SceneType) {
2
+ SceneType[SceneType["EXECUTE"] = 1] = "EXECUTE";
3
+ SceneType[SceneType["AUTO"] = 2] = "AUTO";
4
+ return SceneType;
5
+ }({});
@@ -1,6 +1,6 @@
1
1
  export function routeScene(sceneId) {
2
2
  ty.router({
3
- url: "tuyaSmart://editScene?sceneId=".concat(sceneId, "&biz_type=ai_smart&action=edit"),
3
+ url: "thingSmart://editScene?sceneId=".concat(sceneId, "&biz_type=ai_smart&action=edit"),
4
4
  fail: err => {
5
5
  console.error('router fail', sceneId, err);
6
6
  ty.showToast({
@@ -0,0 +1,8 @@
1
+ export declare const objectsId: (...objects: any[]) => string;
2
+ export interface Resolvable<T = void> {
3
+ resolve: (value?: T) => void;
4
+ reject: (reason?: any) => void;
5
+ promise: Promise<T>;
6
+ state: 'pending' | 'fulfilled' | 'rejected';
7
+ }
8
+ export declare const createResolvable: <T = void>() => Resolvable<T>;
@@ -0,0 +1,57 @@
1
+ import "core-js/modules/esnext.iterator.constructor.js";
2
+ import "core-js/modules/esnext.iterator.map.js";
3
+ import "core-js/modules/web.dom-collections.iterator.js";
4
+ import { generateId } from '@ray-js/t-agent';
5
+ const wm = new WeakMap();
6
+ export const objectsId = function () {
7
+ for (var _len = arguments.length, objects = new Array(_len), _key = 0; _key < _len; _key++) {
8
+ objects[_key] = arguments[_key];
9
+ }
10
+ if (objects.length === 0) {
11
+ return '0@';
12
+ }
13
+ const keys = objects.map((v, i) => {
14
+ if (v === null) {
15
+ return "".concat(i, "-null");
16
+ }
17
+ if (v === undefined) {
18
+ return "".concat(i, "-undefined");
19
+ }
20
+ const type = typeof v;
21
+ if (type === 'object' || type === 'function') {
22
+ if (wm.has(v)) {
23
+ return wm.get(v);
24
+ }
25
+ const id = generateId(16);
26
+ wm.set(v, id);
27
+ return "".concat(i, "-").concat(id);
28
+ }
29
+ return "".concat(i, "-").concat(v);
30
+ });
31
+ return "".concat(objects.length, "@").concat(keys.join('|'));
32
+ };
33
+ export const createResolvable = () => {
34
+ const ret = {
35
+ resolve: null,
36
+ reject: null,
37
+ promise: null,
38
+ state: 'pending'
39
+ };
40
+ ret.promise = new Promise((resolve, reject) => {
41
+ ret.resolve = value => {
42
+ if (ret.state !== 'pending') {
43
+ return;
44
+ }
45
+ ret.state = 'fulfilled';
46
+ resolve(value);
47
+ };
48
+ ret.reject = reason => {
49
+ if (ret.state !== 'pending') {
50
+ return;
51
+ }
52
+ ret.state = 'rejected';
53
+ reject(reason);
54
+ };
55
+ });
56
+ return ret;
57
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/t-agent-ui-ray",
3
- "version": "0.2.2-beta-1",
3
+ "version": "0.2.3-beta-1",
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": "0dd513ad93a351ad5c00a1ee8993c7b62f03640f"
43
+ "gitHead": "ed9810075246e1261af2fdaa41550070313a98dc"
44
44
  }
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- export declare const WaveformVisualizer: React.MemoExoticComponent<({ amplitudeCount }: {
3
- amplitudeCount: number;
4
- }) => React.JSX.Element>;
@@ -1,54 +0,0 @@
1
- import "core-js/modules/esnext.iterator.constructor.js";
2
- import "core-js/modules/esnext.iterator.map.js";
3
- import "core-js/modules/web.dom-collections.iterator.js";
4
- import React, { useEffect, useState } from 'react';
5
- import { View } from '@ray-js/ray';
6
- export const WaveformVisualizer = /*#__PURE__*/React.memo(_ref => {
7
- let {
8
- amplitudeCount
9
- } = _ref;
10
- const [bars, setBars] = useState(() => Array.from({
11
- length: amplitudeCount
12
- }, (_, index) => /*#__PURE__*/React.createElement(View
13
- // eslint-disable-next-line react/no-array-index-key
14
- , {
15
- key: "asr_wave_".concat(index),
16
- className: "t-agent-message-input-waveform-bar",
17
- style: {
18
- height: 0,
19
- // 添加渐变色偏移效果
20
- animationDelay: "".concat(index * 10, "ms")
21
- }
22
- })));
23
- useEffect(() => {
24
- const handle = _ref2 => {
25
- let {
26
- amplitudes
27
- } = _ref2;
28
- const bars = (amplitudes || []).map((item, index) => {
29
- const value = item > 1 ? 1 : item * 100;
30
- // 将数值映射到高度范围(0-100 → 2px-20px)
31
- // const height = 2 + (value / 100) * 18;
32
- return /*#__PURE__*/React.createElement(View
33
- // eslint-disable-next-line react/no-array-index-key
34
- , {
35
- key: "asr_wave_".concat(index),
36
- className: "t-agent-message-input-waveform-bar",
37
- style: {
38
- height: "".concat(value, "%"),
39
- // 添加渐变色偏移效果
40
- animationDelay: "".concat(index * 10, "ms")
41
- }
42
- });
43
- });
44
- setBars(bars);
45
- };
46
- ty.aistream.onRecordAmplitudes(handle);
47
- return () => {
48
- ty.aistream.offRecordAmplitudes(handle);
49
- };
50
- }, []);
51
- return /*#__PURE__*/React.createElement(View, {
52
- className: "t-agent-message-input-waveform-container"
53
- }, bars);
54
- });
@@ -1,9 +0,0 @@
1
- import React from 'react';
2
- interface Props {
3
- id: string;
4
- className?: string;
5
- children?: React.ReactNode;
6
- containerId: string;
7
- }
8
- export default function LazyView(props: Props): React.JSX.Element;
9
- export {};
@@ -1,57 +0,0 @@
1
- import "core-js/modules/es.regexp.exec.js";
2
- import "core-js/modules/web.dom-collections.iterator.js";
3
- import { View } from '@ray-js/components';
4
- import React, { useEffect, useRef, useState } from 'react';
5
- import { usePageInstance } from '@ray-js/ray';
6
- const queryHeight = id => {
7
- return new Promise(resolve => {
8
- // @ts-ignore
9
- const query = ty.createSelectorQuery();
10
- query.select("#".concat(id)).boundingClientRect(res => {
11
- resolve(res.height);
12
- }).exec();
13
- });
14
- };
15
- export default function LazyView(props) {
16
- const {
17
- id,
18
- className,
19
- children,
20
- containerId
21
- } = props;
22
- const [visible, setVisible] = useState(true);
23
- const heightRef = useRef(0);
24
- const valid = heightRef.current > 0;
25
- console.log();
26
- const page = usePageInstance();
27
- useEffect(() => {
28
- // @ts-ignore
29
- const observer = ty.createIntersectionObserver(page, {
30
- thresholds: [0, 1],
31
- initialRatio: 0
32
- });
33
- observer.relativeTo("#".concat(containerId), {
34
- top: 50,
35
- bottom: 50
36
- }).observe("#".concat(id), res => {
37
- setVisible(res.intersectionRatio > 0);
38
- console.log(id, res);
39
- });
40
- return () => {
41
- observer.disconnect();
42
- };
43
- }, [id, containerId]);
44
- useEffect(() => {
45
- queryHeight(id).then(height => {
46
- console.log('queryHeight', id, height);
47
- heightRef.current = height;
48
- });
49
- }, [id]);
50
- console.log('rerender', id);
51
- return /*#__PURE__*/React.createElement(View, {
52
- className: className,
53
- "data-hide": !visible && valid,
54
- id: id
55
- // style={hide ? { visibility: 'hidden' } : null}
56
- }, children);
57
- }