@ray-js/t-agent-ui-ray 0.2.1-beta.3 → 0.2.2-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/ChatContainer/index.d.ts +2 -1
- package/dist/ChatContainer/index.js +53 -48
- package/dist/EchartsBlockRender/index.js +6 -4
- package/dist/EchartsBlockRender/index.rjs +35 -9
- package/dist/MessageInput/MessageInputAIStream/WaveformVisualizer.d.ts +2 -2
- package/dist/MessageInput/MessageInputAIStream/WaveformVisualizer.js +30 -23
- package/dist/MessageInput/MessageInputAIStream/index.d.ts +8 -0
- package/dist/MessageInput/MessageInputAIStream/index.js +52 -41
- package/dist/MessageInput/index.d.ts +2 -1
- package/dist/MessageInput/index.js +2 -1
- package/dist/MessageList/LazyView.d.ts +9 -0
- package/dist/MessageList/LazyView.js +57 -0
- package/dist/MessageList/ScrollBottomView.d.ts +47 -0
- package/dist/MessageList/ScrollBottomView.js +205 -0
- package/dist/MessageList/index.d.ts +5 -2
- package/dist/MessageList/index.js +26 -88
- package/dist/MessageList/index.less +15 -4
- package/dist/MessageRender/index.less +1 -0
- package/dist/TileRender/index.js +5 -3
- package/dist/contexts.d.ts +18 -6
- package/dist/contexts.js +5 -17
- package/dist/hooks/context.d.ts +4 -4
- package/dist/hooks/context.js +13 -4
- package/dist/hooks/useStableCallback.d.ts +1 -0
- package/dist/hooks/useStableCallback.js +13 -0
- package/dist/tiles/BubbleTile/index.js +4 -4
- package/dist/tiles/ExecuteCardTile/index.d.ts +1 -8
- package/dist/tiles/ExecuteCardTile/index.js +7 -15
- package/dist/tiles/ExecuteCardTile/index.less +177 -151
- package/dist/tiles/OperateCardTile/index.d.ts +2 -6
- package/dist/tiles/OperateCardTile/index.js +6 -4
- package/dist/tiles/types.d.ts +31 -0
- package/dist/tiles/types.js +5 -0
- package/dist/types.d.ts +1 -0
- package/dist/utils/createSharedStore.d.ts +4 -0
- package/dist/utils/createSharedStore.js +64 -0
- package/dist/utils/index.js +1 -1
- package/package.json +2 -2
|
@@ -4,23 +4,13 @@ import "core-js/modules/esnext.iterator.for-each.js";
|
|
|
4
4
|
import "core-js/modules/esnext.iterator.map.js";
|
|
5
5
|
import { Image, Switch, Text, View } from '@ray-js/components';
|
|
6
6
|
import React, { useMemo } from 'react';
|
|
7
|
-
// import {
|
|
8
|
-
// ChangeInfoItem,
|
|
9
|
-
// DeviceInfoItem,
|
|
10
|
-
// SceneInfoItem,
|
|
11
|
-
// SceneType,
|
|
12
|
-
// } from '@ray-js/t-agent-plugin-assistant';
|
|
13
7
|
import './index.less';
|
|
14
8
|
import { triggerRule } from '@ray-js/ray';
|
|
15
9
|
import { routeScene } from '../../utils';
|
|
16
10
|
import lockPng from '../OperateCardTile/lock.png';
|
|
17
11
|
import bookmark from './bookmark.png';
|
|
18
12
|
import { useTranslate } from '../../hooks';
|
|
19
|
-
|
|
20
|
-
SceneType[SceneType["EXECUTE"] = 1] = "EXECUTE";
|
|
21
|
-
SceneType[SceneType["AUTO"] = 2] = "AUTO";
|
|
22
|
-
return SceneType;
|
|
23
|
-
}({});
|
|
13
|
+
import { SceneType } from '../types';
|
|
24
14
|
export default function ExecuteCardTile(props) {
|
|
25
15
|
const {
|
|
26
16
|
tile
|
|
@@ -101,7 +91,7 @@ export default function ExecuteCardTile(props) {
|
|
|
101
91
|
} = card;
|
|
102
92
|
if (intent === 'shareDevice') {
|
|
103
93
|
ty.router({
|
|
104
|
-
url: "
|
|
94
|
+
url: "thingSmart://thing_single_device_share?devId=".concat(deviceId),
|
|
105
95
|
fail(err) {
|
|
106
96
|
console.error('router thing_single_device_share fail', err);
|
|
107
97
|
}
|
|
@@ -130,7 +120,7 @@ export default function ExecuteCardTile(props) {
|
|
|
130
120
|
sceneId
|
|
131
121
|
} = card;
|
|
132
122
|
ty.router({
|
|
133
|
-
url: "
|
|
123
|
+
url: "thingSmart://editScene?sceneId=".concat(sceneId, "&biz_type=ai_smart&action=delete"),
|
|
134
124
|
fail: console.error
|
|
135
125
|
});
|
|
136
126
|
};
|
|
@@ -173,7 +163,7 @@ export default function ExecuteCardTile(props) {
|
|
|
173
163
|
}, cards.map(card => {
|
|
174
164
|
return /*#__PURE__*/React.createElement(View, {
|
|
175
165
|
className: "t-agent-execute-card-tile-card",
|
|
176
|
-
key: card.
|
|
166
|
+
key: card.deviceId || card.sceneId
|
|
177
167
|
}, card.displayType === 'device' && /*#__PURE__*/React.createElement(View, {
|
|
178
168
|
className: "t-agent-execute-card-tile-device",
|
|
179
169
|
onClick: () => handleTap(card)
|
|
@@ -181,7 +171,9 @@ export default function ExecuteCardTile(props) {
|
|
|
181
171
|
src: card.icon,
|
|
182
172
|
mode: "widthFix",
|
|
183
173
|
className: "t-agent-execute-card-tile-device-icon"
|
|
184
|
-
}), /*#__PURE__*/React.createElement(View,
|
|
174
|
+
}), /*#__PURE__*/React.createElement(View, {
|
|
175
|
+
className: "t-agent-execute-card-tile-device-title"
|
|
176
|
+
}, card.name)), card.displayType === 'energy' && /*#__PURE__*/React.createElement(View, {
|
|
185
177
|
className: "t-agent-execute-card-tile-energy",
|
|
186
178
|
onClick: () => handleTap(card)
|
|
187
179
|
}, /*#__PURE__*/React.createElement(Image, {
|
|
@@ -1,154 +1,180 @@
|
|
|
1
1
|
.t-agent-execute-card-tile {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
font-size: 12px;
|
|
144
|
-
font-weight: 600;
|
|
145
|
-
color: #e36468;
|
|
146
|
-
background-color: #ffffff;
|
|
147
|
-
display: flex;
|
|
148
|
-
justify-content: center;
|
|
149
|
-
align-items: center;
|
|
150
|
-
border-radius: 18px;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
2
|
+
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.t-agent-execute-card-tile-card {
|
|
6
|
+
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.t-agent-execute-card-tile-device {
|
|
10
|
+
display: flex;
|
|
11
|
+
align-items: center;
|
|
12
|
+
min-height: 44px;
|
|
13
|
+
background-color: var(--app-B1);
|
|
14
|
+
padding: 12px;
|
|
15
|
+
border-radius: var(--app-C1_1);
|
|
16
|
+
margin-top: 8px;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.t-agent-execute-card-tile-device-icon {
|
|
20
|
+
width: 40px;
|
|
21
|
+
height: 40px;
|
|
22
|
+
margin-right: 10px;
|
|
23
|
+
flex-shrink: 0;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.t-agent-execute-card-tile-device-title {
|
|
27
|
+
font-size: 16px;
|
|
28
|
+
line-height: 22px;
|
|
29
|
+
color: var(--app-C1);
|
|
30
|
+
overflow: hidden;
|
|
31
|
+
text-overflow: ellipsis;
|
|
32
|
+
display: -webkit-box;
|
|
33
|
+
-webkit-line-clamp: 2;
|
|
34
|
+
-webkit-box-orient: vertical;
|
|
35
|
+
word-break: normal;
|
|
36
|
+
min-width: 200rpx;
|
|
37
|
+
overflow-wrap: break-word;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.t-agent-execute-card-tile-energy {
|
|
41
|
+
display: flex;
|
|
42
|
+
align-items: center;
|
|
43
|
+
min-height: 44px;
|
|
44
|
+
background-color: var(--app-B1);
|
|
45
|
+
padding: 12px;
|
|
46
|
+
border-radius: var(--app-C1_1);
|
|
47
|
+
margin-top: 8px;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.t-agent-execute-card-tile-energy-icon {
|
|
51
|
+
width: 32px;
|
|
52
|
+
height: 32px;
|
|
53
|
+
border-radius: 4px;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.t-agent-execute-card-tile-energy-content {
|
|
57
|
+
margin-left: 8px;
|
|
58
|
+
flex: 1;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.t-agent-execute-card-tile-energy-content-title {
|
|
62
|
+
font-size: 16px;
|
|
63
|
+
color: var(--app-C1);
|
|
64
|
+
line-height: 22px;
|
|
65
|
+
overflow: hidden;
|
|
66
|
+
text-overflow: ellipsis;
|
|
67
|
+
display: -webkit-box;
|
|
68
|
+
-webkit-line-clamp: 2;
|
|
69
|
+
-webkit-box-orient: vertical;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.t-agent-execute-card-tile-energy-content-desc {
|
|
73
|
+
font-size: 13px;
|
|
74
|
+
color: var(--app-B1-N3);
|
|
75
|
+
line-height: 18px;
|
|
76
|
+
overflow: hidden;
|
|
77
|
+
text-overflow: ellipsis;
|
|
78
|
+
display: -webkit-box;
|
|
79
|
+
-webkit-line-clamp: 2;
|
|
80
|
+
-webkit-box-orient: vertical;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.t-agent-execute-card-tile-scene {
|
|
84
|
+
min-height: 44px;
|
|
85
|
+
background-color: var(--app-B1);
|
|
86
|
+
display: flex;
|
|
87
|
+
align-items: center;
|
|
88
|
+
padding: 12px;
|
|
89
|
+
border-radius: var(--app-C1_1);
|
|
90
|
+
margin-top: 8px;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.t-agent-execute-card-tile-scene-icon-wrapper {
|
|
94
|
+
display: flex;
|
|
95
|
+
justify-content: center;
|
|
96
|
+
align-items: center;
|
|
97
|
+
width: 32px;
|
|
98
|
+
height: 32px;
|
|
99
|
+
border-radius: 10px;
|
|
100
|
+
margin-right: 8px;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.t-agent-execute-card-tile-scene-icon {
|
|
104
|
+
width: 20px;
|
|
105
|
+
height: 20px;
|
|
106
|
+
filter: brightness(100);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.t-agent-execute-card-tile-scene-name {
|
|
110
|
+
flex: 1;
|
|
111
|
+
font-size: 16px;
|
|
112
|
+
line-height: 22px;
|
|
113
|
+
color: var(--app-C1);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.t-agent-execute-card-tile-scene-switch {
|
|
117
|
+
margin-left: auto;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.t-agent-execute-card-tile-scene-delete {
|
|
121
|
+
display: flex;
|
|
122
|
+
align-items: center;
|
|
123
|
+
height: 24px;
|
|
124
|
+
padding-right: 12px;
|
|
125
|
+
padding-left: 12px;
|
|
126
|
+
color: var(--app-M2);
|
|
127
|
+
background: #fff;
|
|
128
|
+
border-radius: var(--app-C1_1);
|
|
129
|
+
font-size: 12px;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.t-agent-execute-card-tile-execute {
|
|
133
|
+
display: flex;
|
|
134
|
+
align-items: center;
|
|
135
|
+
min-height: 44px;
|
|
136
|
+
background-color: #e36468;
|
|
137
|
+
padding: 12px;
|
|
138
|
+
border-radius: var(--app-C1_1);
|
|
139
|
+
margin-top: 8px;
|
|
140
|
+
|
|
141
|
+
&.t-agent-execute-card-tile-execute-disabled {
|
|
142
|
+
opacity: 0.3;
|
|
153
143
|
}
|
|
154
144
|
}
|
|
145
|
+
|
|
146
|
+
.t-agent-execute-card-tile-execute-icon {
|
|
147
|
+
width: 40px;
|
|
148
|
+
height: 40px;
|
|
149
|
+
margin-right: 10px;
|
|
150
|
+
flex-shrink: 0;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.t-agent-execute-card-tile-execute-name {
|
|
154
|
+
font-size: 16px;
|
|
155
|
+
line-height: 22px;
|
|
156
|
+
color: #ffffff;
|
|
157
|
+
overflow: hidden;
|
|
158
|
+
text-overflow: ellipsis;
|
|
159
|
+
display: -webkit-box;
|
|
160
|
+
-webkit-line-clamp: 2;
|
|
161
|
+
-webkit-box-orient: vertical;
|
|
162
|
+
min-width: 200rpx;
|
|
163
|
+
word-break: normal;
|
|
164
|
+
overflow-wrap: break-word;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.t-agent-execute-card-tile-execute-button {
|
|
168
|
+
margin-left: auto;
|
|
169
|
+
line-height: 18px;
|
|
170
|
+
padding: 3px 12px;
|
|
171
|
+
font-size: 12px;
|
|
172
|
+
font-weight: 600;
|
|
173
|
+
color: #e36468;
|
|
174
|
+
background-color: #ffffff;
|
|
175
|
+
display: flex;
|
|
176
|
+
justify-content: center;
|
|
177
|
+
align-items: center;
|
|
178
|
+
border-radius: 18px;
|
|
179
|
+
flex-shrink: 0;
|
|
180
|
+
}
|
|
@@ -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
|
-
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
import { useTranslate } from '../../hooks';
|
|
8
|
+
import { useTileProps, useTranslate } from '../../hooks';
|
|
11
9
|
import Expand from './Expand';
|
|
12
10
|
import { formatMessage } from '../../utils';
|
|
13
11
|
const handleDesc = (detail, t) => {
|
|
@@ -100,7 +98,7 @@ export default function OperateCardTile(props) {
|
|
|
100
98
|
const tapScene = e => {
|
|
101
99
|
const sceneId = e.currentTarget.dataset.id;
|
|
102
100
|
ty.router({
|
|
103
|
-
url: "
|
|
101
|
+
url: "thingSmart://editScene?sceneId=".concat(sceneId, "&biz_type=ai_smart&action=edit"),
|
|
104
102
|
fail: () => {
|
|
105
103
|
ty.showToast({
|
|
106
104
|
title: t('t-agent.operate-card-tile.open.scene.failed'),
|
|
@@ -197,6 +195,9 @@ export default function OperateCardTile(props) {
|
|
|
197
195
|
};
|
|
198
196
|
}, [deviceInfo, sceneInfo, changeInfo, t]);
|
|
199
197
|
const desc = useMemo(() => handleDesc(operations, t), [operations, t]);
|
|
198
|
+
const {
|
|
199
|
+
notifyHeightChanged
|
|
200
|
+
} = useTileProps();
|
|
200
201
|
if (!operations.device.length && !operations.scene.length && !operations.moreDevice.length && !operations.moreScene.length) {
|
|
201
202
|
return null;
|
|
202
203
|
}
|
|
@@ -208,6 +209,7 @@ export default function OperateCardTile(props) {
|
|
|
208
209
|
className: "t-agent-scene-control-tile-summary-detail",
|
|
209
210
|
onClick: () => {
|
|
210
211
|
setShowDetail(!showDetail);
|
|
212
|
+
notifyHeightChanged();
|
|
211
213
|
}
|
|
212
214
|
}, showDetail ? t('t-agent.operate-card-tile.hide.details') : t('t-agent.operate-card-tile.view.details'))), renderDetail && renderDetail({
|
|
213
215
|
operations,
|
|
@@ -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
|
+
}
|
package/dist/types.d.ts
CHANGED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React, { PropsWithChildren } from 'react';
|
|
2
|
+
export declare function createSharedStore<T>(): readonly [({ value, children }: React.PropsWithChildren<{
|
|
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]];
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import "core-js/modules/esnext.iterator.constructor.js";
|
|
3
|
+
import "core-js/modules/esnext.iterator.for-each.js";
|
|
4
|
+
import "core-js/modules/web.dom-collections.iterator.js";
|
|
5
|
+
import React, { createContext, useContext, useRef, useState, useEffect, useLayoutEffect } from 'react';
|
|
6
|
+
export function createSharedStore() {
|
|
7
|
+
const Context = /*#__PURE__*/createContext(null);
|
|
8
|
+
return [function (_ref) {
|
|
9
|
+
let {
|
|
10
|
+
value,
|
|
11
|
+
children
|
|
12
|
+
} = _ref;
|
|
13
|
+
const storeRef = useRef({
|
|
14
|
+
value,
|
|
15
|
+
listeners: new Map(),
|
|
16
|
+
setValue(newValue) {
|
|
17
|
+
const oldValue = storeRef.current.value;
|
|
18
|
+
storeRef.current.value = newValue;
|
|
19
|
+
for (const key of Object.keys(newValue)) {
|
|
20
|
+
if (oldValue[key] !== newValue[key]) {
|
|
21
|
+
var _storeRef$current$lis;
|
|
22
|
+
(_storeRef$current$lis = storeRef.current.listeners.get(key)) === null || _storeRef$current$lis === void 0 || _storeRef$current$lis.forEach(fn => fn());
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
updateKey(key, val) {
|
|
27
|
+
const newValue = _objectSpread(_objectSpread({}, storeRef.current.value), {}, {
|
|
28
|
+
[key]: val
|
|
29
|
+
});
|
|
30
|
+
storeRef.current.setValue(newValue);
|
|
31
|
+
},
|
|
32
|
+
subscribe(key, fn) {
|
|
33
|
+
if (!storeRef.current.listeners.has(key)) {
|
|
34
|
+
storeRef.current.listeners.set(key, new Set());
|
|
35
|
+
}
|
|
36
|
+
storeRef.current.listeners.get(key).add(fn);
|
|
37
|
+
return () => {
|
|
38
|
+
storeRef.current.listeners.get(key).delete(fn);
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
useLayoutEffect(() => {
|
|
43
|
+
// ✅ 在 render 阶段同步设置最新 value
|
|
44
|
+
storeRef.current.setValue(value);
|
|
45
|
+
}, [value]);
|
|
46
|
+
return /*#__PURE__*/React.createElement(Context.Provider, {
|
|
47
|
+
value: storeRef.current
|
|
48
|
+
}, children);
|
|
49
|
+
}, function (key) {
|
|
50
|
+
const store = useContext(Context);
|
|
51
|
+
if (!store) throw new Error('useSharedValue must be used within Provider');
|
|
52
|
+
const [, forceUpdate] = useState(0);
|
|
53
|
+
useEffect(() => store.subscribe(key, () => forceUpdate(n => n + 1)), [key, store]);
|
|
54
|
+
return store.value[key];
|
|
55
|
+
}, function (key) {
|
|
56
|
+
const store = useContext(Context);
|
|
57
|
+
if (!store) throw new Error('useSharedState must be used within Provider');
|
|
58
|
+
const [, forceUpdate] = useState(0);
|
|
59
|
+
useEffect(() => store.subscribe(key, () => forceUpdate(n => n + 1)), [key, store]);
|
|
60
|
+
return [store.value[key], val => {
|
|
61
|
+
store.updateKey(key, val);
|
|
62
|
+
}];
|
|
63
|
+
}];
|
|
64
|
+
}
|
package/dist/utils/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export function routeScene(sceneId) {
|
|
2
2
|
ty.router({
|
|
3
|
-
url: "
|
|
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({
|
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.2-beta-2",
|
|
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": "33a1985d3a14487fe5f354411b0c46c8a8af19c7"
|
|
44
44
|
}
|