@blocklet/pages-kit 0.2.326 → 0.2.328
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/lib/cjs/builtin/async/ai-runtime/components/Header/SimpleHeader.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/components/ThemeProvider.js +47 -29
- package/lib/cjs/builtin/async/ai-runtime/components/UserInfo.js +4 -6
- package/lib/cjs/builtin/async/ai-runtime/locales/index.js +10 -4
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/MessageView.js +6 -4
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/OpeningMessageView.js +3 -2
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/index.js +4 -1
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/Page.js +15 -6
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/components/CodePreview.js +74 -19
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/components/TransparentTooltip.js +25 -0
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/components/UserQuestion.js +8 -3
- package/lib/cjs/components/CustomComponentRenderer/index.js +3 -2
- package/lib/cjs/components/CustomComponentRenderer/state.js +1 -1
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/esm/builtin/async/ai-runtime/components/Header/SimpleHeader.js +1 -1
- package/lib/esm/builtin/async/ai-runtime/components/ThemeProvider.js +48 -30
- package/lib/esm/builtin/async/ai-runtime/components/UserInfo.js +4 -6
- package/lib/esm/builtin/async/ai-runtime/locales/index.js +10 -4
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/MessageView.js +6 -4
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/OpeningMessageView.js +3 -2
- package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/index.js +5 -2
- package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/Page.js +15 -6
- package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/components/CodePreview.js +73 -18
- package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/components/TransparentTooltip.js +23 -0
- package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/components/UserQuestion.js +8 -3
- package/lib/esm/components/CustomComponentRenderer/index.js +3 -2
- package/lib/esm/components/CustomComponentRenderer/state.js +1 -1
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/lib/types/builtin/async/ai-runtime/api/agent.d.ts +9 -1
- package/lib/types/builtin/async/ai-runtime/components/UserInfo.d.ts +2 -1
- package/lib/types/builtin/async/ai-runtime/locales/index.d.ts +6 -0
- package/lib/types/builtin/async/ai-runtime/runtime-components/V0/components/CodePreview.d.ts +2 -1
- package/lib/types/builtin/async/ai-runtime/runtime-components/V0/components/TransparentTooltip.d.ts +3 -0
- package/lib/types/components/CustomComponentRenderer/index.d.ts +1 -0
- package/lib/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -6
|
@@ -44,6 +44,6 @@ function SimpleHeader(_a) {
|
|
|
44
44
|
const { agent } = (0, runtime_1.useRuntimeState)();
|
|
45
45
|
const title = agent.project.name;
|
|
46
46
|
const { description } = agent.project;
|
|
47
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Stack, Object.assign({ gap: 2, mt: 8, mb: 4 }, props, { className: (0, css_1.cx)('aigne-header aigne-simple-header', props.className), children: (0, jsx_runtime_1.jsxs)(react_wrap_balancer_1.Provider, { children: [title && ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ width: "100%",
|
|
47
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Stack, Object.assign({ gap: 2, mt: 8, mb: 4 }, props, { className: (0, css_1.cx)('aigne-header aigne-simple-header', props.className), children: (0, jsx_runtime_1.jsxs)(react_wrap_balancer_1.Provider, { children: [title && ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ width: "100%", variant: "h4", fontSize: 30, fontWeight: 700, textAlign: "center" }, TitleProps, { children: (0, jsx_runtime_1.jsx)(react_wrap_balancer_1.default, { children: title }) }))), description && ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ width: "100%", textAlign: "center" }, DescriptionProps, { children: (0, jsx_runtime_1.jsx)(react_wrap_balancer_1.default, { children: description }) })))] }) })));
|
|
48
48
|
}
|
|
49
49
|
exports.default = SimpleHeader;
|
|
@@ -21,18 +21,32 @@ const react_1 = require("react");
|
|
|
21
21
|
const runtime_1 = require("../state/runtime");
|
|
22
22
|
const GlobalLoading_1 = __importDefault(require("./GlobalLoading"));
|
|
23
23
|
function ThemeProvider({ children }) {
|
|
24
|
-
const {
|
|
24
|
+
const { appearance } = (0, runtime_1.useRuntimeState)().agent.project;
|
|
25
25
|
const theme = (0, material_1.useTheme)();
|
|
26
26
|
const newTheme = (0, react_1.useMemo)(() => {
|
|
27
|
+
var _a, _b, _c, _d, _e, _f;
|
|
27
28
|
let { primary } = theme.palette;
|
|
28
29
|
try {
|
|
29
|
-
if (primaryColor) {
|
|
30
|
-
primary = theme.palette.augmentColor({ color: { main: primaryColor } });
|
|
30
|
+
if (appearance === null || appearance === void 0 ? void 0 : appearance.primaryColor) {
|
|
31
|
+
primary = theme.palette.augmentColor({ color: { main: appearance === null || appearance === void 0 ? void 0 : appearance.primaryColor } });
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
34
|
catch (error) {
|
|
34
35
|
console.error('augment primary color error', { error });
|
|
35
36
|
}
|
|
37
|
+
const { fontFamily } = theme.typography;
|
|
38
|
+
const headingFontFamily = [
|
|
39
|
+
((_b = (_a = appearance === null || appearance === void 0 ? void 0 : appearance.typography) === null || _a === void 0 ? void 0 : _a.heading) === null || _b === void 0 ? void 0 : _b.fontFamily) && JSON.stringify((_d = (_c = appearance === null || appearance === void 0 ? void 0 : appearance.typography) === null || _c === void 0 ? void 0 : _c.heading) === null || _d === void 0 ? void 0 : _d.fontFamily),
|
|
40
|
+
fontFamily,
|
|
41
|
+
]
|
|
42
|
+
.filter(Boolean)
|
|
43
|
+
.join(',');
|
|
44
|
+
const bodyFontFamily = [
|
|
45
|
+
((_e = appearance === null || appearance === void 0 ? void 0 : appearance.typography) === null || _e === void 0 ? void 0 : _e.fontFamily) && JSON.stringify((_f = appearance === null || appearance === void 0 ? void 0 : appearance.typography) === null || _f === void 0 ? void 0 : _f.fontFamily),
|
|
46
|
+
fontFamily,
|
|
47
|
+
]
|
|
48
|
+
.filter(Boolean)
|
|
49
|
+
.join(',');
|
|
36
50
|
const themeOptions = {
|
|
37
51
|
components: {
|
|
38
52
|
MuiSelect: {
|
|
@@ -98,30 +112,28 @@ function ThemeProvider({ children }) {
|
|
|
98
112
|
},
|
|
99
113
|
},
|
|
100
114
|
};
|
|
101
|
-
const
|
|
115
|
+
const tempTheme = (0, material_1.createTheme)({
|
|
116
|
+
typography: Object.assign({ fontFamily: bodyFontFamily }, Object.fromEntries(new Array(5).fill(0).map((_, index) => [
|
|
117
|
+
`h${index + 1}`,
|
|
118
|
+
{
|
|
119
|
+
fontFamily: headingFontFamily,
|
|
120
|
+
},
|
|
121
|
+
]))),
|
|
102
122
|
palette: {
|
|
103
123
|
primary,
|
|
104
124
|
secondary: {
|
|
105
125
|
main: '#010714',
|
|
106
126
|
},
|
|
107
|
-
text: {
|
|
108
|
-
secondary: '#98A3B1',
|
|
109
|
-
// @ts-ignore
|
|
110
|
-
poweredBy: 'rgba(209, 213, 219, 1)',
|
|
111
|
-
},
|
|
112
|
-
// @ts-ignore custom `black` color
|
|
113
|
-
black: {
|
|
114
|
-
main: '#010714',
|
|
115
|
-
},
|
|
116
127
|
},
|
|
117
128
|
});
|
|
118
129
|
return (0, material_1.createTheme)(theme, themeOptions, {
|
|
130
|
+
typography: tempTheme.typography,
|
|
119
131
|
palette: {
|
|
120
|
-
primary:
|
|
121
|
-
secondary:
|
|
122
|
-
text:
|
|
132
|
+
primary: tempTheme.palette.primary,
|
|
133
|
+
secondary: tempTheme.palette.secondary,
|
|
134
|
+
text: tempTheme.palette.text,
|
|
123
135
|
// @ts-ignore
|
|
124
|
-
black:
|
|
136
|
+
black: tempTheme.palette.black,
|
|
125
137
|
background: {
|
|
126
138
|
default: '#ffffff',
|
|
127
139
|
},
|
|
@@ -133,20 +145,26 @@ function ThemeProvider({ children }) {
|
|
|
133
145
|
'none',
|
|
134
146
|
'0px 0px 0px 1px rgba(2, 7, 19, 0.08), 0px 1px 2px -1px rgba(2, 7, 19, 0.08), 0px 2px 4px 0px rgba(2, 7, 19, 0.04)',
|
|
135
147
|
'0px 0px 0px 1px rgba(2, 7, 19, 0.08), 0px 1px 2px -1px rgba(2, 7, 19, 0.08), 0px 2px 8px 0px rgba(2, 7, 19, 0.10)',
|
|
136
|
-
...
|
|
148
|
+
...tempTheme.shadows.slice(3),
|
|
137
149
|
],
|
|
138
150
|
});
|
|
139
151
|
}, [theme]);
|
|
140
|
-
return ((0, jsx_runtime_1.
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
152
|
+
return ((0, jsx_runtime_1.jsx)(material_1.ThemeProvider, { theme: newTheme, children: (0, jsx_runtime_1.jsxs)(material_1.CssBaseline, { children: [(0, jsx_runtime_1.jsx)(material_1.GlobalStyles, { styles: (theme) => theme.unstable_sx({
|
|
153
|
+
'h1,h2,h3,h4,h5': {
|
|
154
|
+
fontFamily: `${theme.typography.h1.fontFamily} !important`,
|
|
155
|
+
},
|
|
156
|
+
body: {
|
|
157
|
+
fontFamily: `${theme.typography.fontFamily} !important`,
|
|
158
|
+
},
|
|
159
|
+
'.page-header': {
|
|
160
|
+
borderBottom: '1px solid rgba(229, 231, 235, 1)',
|
|
161
|
+
},
|
|
162
|
+
'.white-tooltip .MuiTooltip-tooltip': {
|
|
163
|
+
background: 'white !important',
|
|
164
|
+
boxShadow: '0px 4px 8px 0px rgba(3, 7, 18, 0.08)',
|
|
165
|
+
border: '1px solid rgba(229, 231, 235, 1)',
|
|
166
|
+
padding: 4,
|
|
167
|
+
},
|
|
168
|
+
}) }), (0, jsx_runtime_1.jsx)(GlobalLoading_1.default, { sx: { position: 'fixed', left: 0, top: 0, width: '100%', zIndex: 'snackbar' } }), (0, jsx_runtime_1.jsx)(react_1.Suspense, { fallback: (0, jsx_runtime_1.jsx)(material_1.Stack, { flexGrow: 1, alignItems: "center", justifyContent: "center", children: (0, jsx_runtime_1.jsx)(material_1.CircularProgress, { size: 24 }) }), children: children })] }) }));
|
|
151
169
|
}
|
|
152
170
|
exports.default = ThemeProvider;
|
|
@@ -22,18 +22,16 @@ const dayjs_1 = __importDefault(require("dayjs"));
|
|
|
22
22
|
const react_1 = require("react");
|
|
23
23
|
const ux_1 = require("../../../arcblock/ux");
|
|
24
24
|
function UserInfo(_a) {
|
|
25
|
-
var { avatar, showDID, did, name, time, children, reverse } = _a, restProps = __rest(_a, ["avatar", "showDID", "did", "name", "time", "children", "reverse"]);
|
|
25
|
+
var { avatar, showDID, did, name, time, children, reverse, UserNameProps } = _a, restProps = __rest(_a, ["avatar", "showDID", "did", "name", "time", "children", "reverse", "UserNameProps"]);
|
|
26
26
|
return ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: "user-info", alignItems: "center", direction: reverse ? 'row-reverse' : 'row', gap: 1.5 }, restProps, { children: [(avatar || did) && ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
|
|
27
27
|
display: 'flex',
|
|
28
28
|
alignItems: 'center',
|
|
29
29
|
maxHeight: 44,
|
|
30
|
-
}, children: (0, jsx_runtime_1.jsx)(ux_1.Avatar, { size: 40, did: did, variant: "circle", shape: "circle", src: avatar }) })), (0, jsx_runtime_1.jsxs)(material_1.Box, { flex: 1, width: 0, children: [(0, jsx_runtime_1.jsxs)(UserName, { sx: {
|
|
31
|
-
justifyContent: reverse ? 'flex-end' : 'flex-start',
|
|
32
|
-
}, children: [name || '', time && ((0, jsx_runtime_1.jsx)(UserTime, { time: time, sx: {
|
|
30
|
+
}, children: (0, jsx_runtime_1.jsx)(ux_1.Avatar, { size: 40, did: did, variant: "circle", shape: "circle", src: avatar }) })), (0, jsx_runtime_1.jsxs)(material_1.Box, { flex: 1, width: 0, children: [(0, jsx_runtime_1.jsxs)(UserName, Object.assign({}, UserNameProps, { sx: Object.assign({ justifyContent: reverse ? 'flex-end' : 'flex-start' }, UserNameProps === null || UserNameProps === void 0 ? void 0 : UserNameProps.sx), children: [name || '', time && ((0, jsx_runtime_1.jsx)(UserTime, { time: time, sx: {
|
|
33
31
|
fontSize: 12,
|
|
34
32
|
lineHeight: '24px',
|
|
35
|
-
|
|
36
|
-
} }))] }), showDID && did && (0, jsx_runtime_1.jsx)(material_1.Box, { component: DID_1.default, did: did, copyable: false, size: 14, responsive: true, sx: { mt: -0.25 } }), (0, jsx_runtime_1.jsx)(material_1.Box, { flex: 1, children: children })] })] })));
|
|
33
|
+
opacity: 0.8,
|
|
34
|
+
} }))] })), showDID && did && (0, jsx_runtime_1.jsx)(material_1.Box, { component: DID_1.default, did: did, copyable: false, size: 14, responsive: true, sx: { mt: -0.25 } }), (0, jsx_runtime_1.jsx)(material_1.Box, { flex: 1, children: children })] })] })));
|
|
37
35
|
}
|
|
38
36
|
exports.default = UserInfo;
|
|
39
37
|
function UserName(_a) {
|
|
@@ -97,8 +97,8 @@ exports.translations = {
|
|
|
97
97
|
session: 'Session',
|
|
98
98
|
loadMore: 'Load More',
|
|
99
99
|
v0: {
|
|
100
|
-
title: '
|
|
101
|
-
description: '
|
|
100
|
+
title: 'Mock 0',
|
|
101
|
+
description: 'Mock 0 is an AI-based code tool that can help you generate code quickly.',
|
|
102
102
|
noData: 'No conversation information yet, click the button below to start generating!',
|
|
103
103
|
deleteSessionTitle: 'Delete Conversation Information',
|
|
104
104
|
deleteSessionTip: 'Are you sure you want to delete this Conversation Information?',
|
|
@@ -109,6 +109,9 @@ exports.translations = {
|
|
|
109
109
|
codePreviewTip: 'Here is the code preview, you can view the generated code, and editing is not supported yet.',
|
|
110
110
|
hideSlider: 'Hide Versions',
|
|
111
111
|
showSlider: 'Show Versions',
|
|
112
|
+
retryTip: 'Agent not enough power, please try again later...',
|
|
113
|
+
retry: 'Try Again',
|
|
114
|
+
errorCodeTip: 'Agent found some syntax errors in the code, and want to try again...',
|
|
112
115
|
},
|
|
113
116
|
},
|
|
114
117
|
zh: {
|
|
@@ -206,8 +209,8 @@ exports.translations = {
|
|
|
206
209
|
session: '会话',
|
|
207
210
|
loadMore: '加载更多',
|
|
208
211
|
v0: {
|
|
209
|
-
title: '
|
|
210
|
-
description: '
|
|
212
|
+
title: 'Mock 0',
|
|
213
|
+
description: 'Mock 0 是一个基于人工智能的代码工具,可以帮助您快速生成代码。',
|
|
211
214
|
noData: '暂无生成记录,点击下方按钮开始生成吧!',
|
|
212
215
|
deleteSessionTitle: '删除生成记录',
|
|
213
216
|
deleteSessionTip: '确定要删除此生成记录吗?',
|
|
@@ -218,6 +221,9 @@ exports.translations = {
|
|
|
218
221
|
codePreviewTip: '以下是代码预览,您可以查看生成的代码,目前还不支持编辑。',
|
|
219
222
|
hideSlider: '隐藏版本历史',
|
|
220
223
|
showSlider: '显示版本历史',
|
|
224
|
+
retryTip: 'Agent 算力不足,请稍后重试...',
|
|
225
|
+
retry: '重试',
|
|
226
|
+
errorCodeTip: 'Agent 发现代码存在一些语法错误,请求重试...',
|
|
221
227
|
},
|
|
222
228
|
},
|
|
223
229
|
};
|
|
@@ -50,15 +50,17 @@ const CurrentMessage_1 = __importDefault(require("../../contexts/CurrentMessage"
|
|
|
50
50
|
const use_appearances_1 = __importStar(require("../../hooks/use-appearances"));
|
|
51
51
|
const UserMessageView_1 = __importDefault(require("./UserMessageView"));
|
|
52
52
|
const MessageView = (0, react_1.memo)(({ message }) => {
|
|
53
|
-
var _a, _b, _c, _d, _e;
|
|
53
|
+
var _a, _b, _c, _d, _e, _f;
|
|
54
|
+
const preferences = (0, ComponentPreferences_1.useComponentPreferences)();
|
|
55
|
+
const hasBg = !!((_a = preferences === null || preferences === void 0 ? void 0 : preferences.backgroundImage) === null || _a === void 0 ? void 0 : _a.url);
|
|
54
56
|
const { session: authSession } = (0, session_1.useSessionContext)();
|
|
55
57
|
const { appearanceOutput } = (0, use_appearances_1.default)({ agentId: message.assistantId });
|
|
56
58
|
const profile = (0, use_appearances_1.useProfile)({ agentId: message.assistantId });
|
|
57
|
-
const { hideAgentAvatar, hideUserInputs } = (
|
|
59
|
+
const { hideAgentAvatar, hideUserInputs } = (_b = (0, ComponentPreferences_1.useComponentPreferences)()) !== null && _b !== void 0 ? _b : {};
|
|
58
60
|
if (!(appearanceOutput === null || appearanceOutput === void 0 ? void 0 : appearanceOutput.componentId))
|
|
59
61
|
return null;
|
|
60
62
|
const agentMessage = ((0, jsx_runtime_1.jsx)(MessageBodyContainer, { messageRole: "assistant", children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: appearanceOutput.componentId, properties: appearanceOutput.componentProperties }) }));
|
|
61
|
-
return ((0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: message.assistantId, children: (0, jsx_runtime_1.jsx)(CurrentMessage_1.default, { message: message, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: 2, children: [!hideUserInputs && ((0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsx)(UserInfo_1.default, { name: (
|
|
63
|
+
return ((0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: message.assistantId, children: (0, jsx_runtime_1.jsx)(CurrentMessage_1.default, { message: message, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { gap: 2, children: [!hideUserInputs && ((0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsx)(UserInfo_1.default, { name: (_c = authSession.user) === null || _c === void 0 ? void 0 : _c.fullName, did: (_d = authSession.user) === null || _d === void 0 ? void 0 : _d.did, avatar: (_e = authSession.user) === null || _e === void 0 ? void 0 : _e.avatar, time: message.createdAt, reverse: true, alignItems: "flex-start", UserNameProps: { sx: { color: hasBg ? 'white' : undefined } }, children: (0, jsx_runtime_1.jsx)(material_1.Stack, { sx: { alignItems: 'flex-end' }, children: (0, jsx_runtime_1.jsx)(MessageBodyContainer, { messageRole: "user", children: (0, jsx_runtime_1.jsx)(UserMessageView_1.default, {}) }) }) }) })), (0, jsx_runtime_1.jsx)(material_1.Box, { children: !hideAgentAvatar ? ((0, jsx_runtime_1.jsx)(UserInfo_1.default, { name: profile.name, did: (_f = globalThis.blocklet) === null || _f === void 0 ? void 0 : _f.appId, avatar: profile.avatar, time: message.createdAt, alignItems: "flex-start", UserNameProps: { sx: { color: hasBg ? 'white' : undefined } }, children: agentMessage })) : (agentMessage) })] }) }) }));
|
|
62
64
|
});
|
|
63
65
|
exports.default = MessageView;
|
|
64
66
|
function MessageBodyContainer(_a) {
|
|
@@ -68,6 +70,6 @@ function MessageBodyContainer(_a) {
|
|
|
68
70
|
const hasBg = !!((_b = preferences === null || preferences === void 0 ? void 0 : preferences.backgroundImage) === null || _b === void 0 ? void 0 : _b.url);
|
|
69
71
|
const hideUserMessage = preferences === null || preferences === void 0 ? void 0 : preferences.hideUserInputs;
|
|
70
72
|
return ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({}, props, { sx: hasBg
|
|
71
|
-
? Object.assign({ borderRadius: 1, borderTopRightRadius: messageRole === 'user' ? 2 : undefined, borderTopLeftRadius: messageRole !== 'user' ? 2 : undefined, px: 2, py: 1, marginTop: 0.5, maxWidth: hideUserMessage ? 'unset' : 'calc(100% - 40px)', bgcolor: 'rgba(
|
|
73
|
+
? Object.assign({ borderRadius: 1, borderTopRightRadius: messageRole === 'user' ? 2 : undefined, borderTopLeftRadius: messageRole !== 'user' ? 2 : undefined, px: 2, py: 1, marginTop: 0.5, maxWidth: hideUserMessage ? 'unset' : 'calc(100% - 40px)', bgcolor: 'rgba(255, 255, 255, 0.8)', backdropFilter: 'blur(16px)' }, props.sx) : Object.assign({}, props.sx) })));
|
|
72
74
|
}
|
|
73
75
|
exports.MessageBodyContainer = MessageBodyContainer;
|
package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/OpeningMessageView.js
CHANGED
|
@@ -15,7 +15,8 @@ const use_appearances_1 = require("../../hooks/use-appearances");
|
|
|
15
15
|
const MessageView_1 = require("./MessageView");
|
|
16
16
|
const OpeningMessageView = (0, react_1.memo)(({ isMessagesEmpty }) => {
|
|
17
17
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
18
|
-
const { hideAgentAvatar } = (_a = (0, ComponentPreferences_1.useComponentPreferences)()) !== null && _a !== void 0 ? _a : {};
|
|
18
|
+
const { hideAgentAvatar, backgroundImage } = (_a = (0, ComponentPreferences_1.useComponentPreferences)()) !== null && _a !== void 0 ? _a : {};
|
|
19
|
+
const hasBg = !!(backgroundImage === null || backgroundImage === void 0 ? void 0 : backgroundImage.url);
|
|
19
20
|
const openingMessage = (0, use_appearances_1.useOpeningMessage)();
|
|
20
21
|
const openingMessageOutput = (0, react_1.useMemo)(() => { var _a; return (_a = openingMessage === null || openingMessage === void 0 ? void 0 : openingMessage.agent.outputVariables) === null || _a === void 0 ? void 0 : _a.find((i) => i.name === types_1.RuntimeOutputVariable.openingMessage); }, [openingMessage === null || openingMessage === void 0 ? void 0 : openingMessage.agent]);
|
|
21
22
|
const openingMessageComponentId = ((_b = openingMessageOutput === null || openingMessageOutput === void 0 ? void 0 : openingMessageOutput.appearance) === null || _b === void 0 ? void 0 : _b.componentId) ||
|
|
@@ -31,6 +32,6 @@ const OpeningMessageView = (0, react_1.memo)(({ isMessagesEmpty }) => {
|
|
|
31
32
|
return null;
|
|
32
33
|
}
|
|
33
34
|
const children = ((0, jsx_runtime_1.jsxs)(MessageView_1.MessageBodyContainer, { children: [openingMessage && openingMessageOutput && openingMessageComponentId && ((0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { instanceId: openingMessageOutput.id, componentId: openingMessageComponentId, properties: (_f = openingMessageOutput.appearance) === null || _f === void 0 ? void 0 : _f.componentProperties, props: { output: openingMessageOutput, outputValue: openingMessage.message } })), isMessagesEmpty && openingQuestionsComponentId && ((0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { instanceId: agent.id, componentId: openingQuestionsComponentId, properties: (_g = openingQuestionsOutput === null || openingQuestionsOutput === void 0 ? void 0 : openingQuestionsOutput.appearance) === null || _g === void 0 ? void 0 : _g.componentProperties, props: { output: openingQuestionsOutput } }))] }));
|
|
34
|
-
return hideAgentAvatar ? (children) : ((0, jsx_runtime_1.jsx)(UserInfo_1.default, { name: ((_h = openingMessage === null || openingMessage === void 0 ? void 0 : openingMessage.profile) !== null && _h !== void 0 ? _h : profile).name, did: (_j = globalThis.blocklet) === null || _j === void 0 ? void 0 : _j.appId, avatar: ((_k = openingMessage === null || openingMessage === void 0 ? void 0 : openingMessage.profile) !== null && _k !== void 0 ? _k : profile).avatar, alignItems: "flex-start", children: children }));
|
|
35
|
+
return hideAgentAvatar ? (children) : ((0, jsx_runtime_1.jsx)(UserInfo_1.default, { name: ((_h = openingMessage === null || openingMessage === void 0 ? void 0 : openingMessage.profile) !== null && _h !== void 0 ? _h : profile).name, did: (_j = globalThis.blocklet) === null || _j === void 0 ? void 0 : _j.appId, avatar: ((_k = openingMessage === null || openingMessage === void 0 ? void 0 : openingMessage.profile) !== null && _k !== void 0 ? _k : profile).avatar, alignItems: "flex-start", UserNameProps: { sx: { color: hasBg ? 'white' : undefined } }, children: children }));
|
|
35
36
|
});
|
|
36
37
|
exports.default = OpeningMessageView;
|
|
@@ -36,6 +36,9 @@ function SimpleChat(_a) {
|
|
|
36
36
|
}
|
|
37
37
|
exports.default = SimpleChat;
|
|
38
38
|
function SimpleChatView() {
|
|
39
|
+
var _a;
|
|
40
|
+
const preferences = (0, ComponentPreferences_1.useComponentPreferences)();
|
|
41
|
+
const hasBg = !!((_a = preferences === null || preferences === void 0 ? void 0 : preferences.backgroundImage) === null || _a === void 0 ? void 0 : _a.url);
|
|
39
42
|
const { activeAgentId } = (0, ActiveAgent_1.useActiveAgent)();
|
|
40
43
|
// auto scroll to bottom when new message is sent
|
|
41
44
|
const running = (0, session_1.useCurrentSessionState)((s) => s === null || s === void 0 ? void 0 : s.running);
|
|
@@ -48,7 +51,7 @@ function SimpleChatView() {
|
|
|
48
51
|
const sessionLoading = (0, session_1.useCurrentSessionState)((s) => s === null || s === void 0 ? void 0 : s.loading);
|
|
49
52
|
const loading = (0, session_1.useSessionState)((s) => s === null || s === void 0 ? void 0 : s.loading) || sessionLoading;
|
|
50
53
|
(0, use_header_menu_1.useHeaderMenu)();
|
|
51
|
-
return ((0, jsx_runtime_1.jsxs)(SimpleLayout_1.default, { px: 0, children: [(0, jsx_runtime_1.jsx)(SimpleHeader_1.default, { px: 4 }), loading ? ((0, jsx_runtime_1.jsx)(material_1.Box, { textAlign: "center", my: 10, children: (0, jsx_runtime_1.jsx)(material_1.CircularProgress, { size: 24 }) })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: activeAgentId, children: (0, jsx_runtime_1.jsx)(MessagesView_1.default, { className: "aigne-outputs aigne-simple-chat-outputs", flexGrow: (messages === null || messages === void 0 ? void 0 : messages.length) ? 1 : 0, pb: (messages === null || messages === void 0 ? void 0 : messages.length) ? 10 : 2, px: { xs: 2, sm: 3 } }) }), (0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: activeAgentId, children: (0, jsx_runtime_1.jsx)(InputsView_1.default, { className: "aigne-inputs aigne-simple-chat-inputs", sx: {
|
|
54
|
+
return ((0, jsx_runtime_1.jsxs)(SimpleLayout_1.default, { px: 0, children: [(0, jsx_runtime_1.jsx)(SimpleHeader_1.default, { px: 4, sx: { color: hasBg ? 'white' : undefined } }), loading ? ((0, jsx_runtime_1.jsx)(material_1.Box, { textAlign: "center", my: 10, children: (0, jsx_runtime_1.jsx)(material_1.CircularProgress, { size: 24 }) })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: activeAgentId, children: (0, jsx_runtime_1.jsx)(MessagesView_1.default, { className: "aigne-outputs aigne-simple-chat-outputs", flexGrow: (messages === null || messages === void 0 ? void 0 : messages.length) ? 1 : 0, pb: (messages === null || messages === void 0 ? void 0 : messages.length) ? 10 : 2, px: { xs: 2, sm: 3 } }) }), (0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: activeAgentId, children: (0, jsx_runtime_1.jsx)(InputsView_1.default, { className: "aigne-inputs aigne-simple-chat-inputs", sx: {
|
|
52
55
|
position: 'sticky',
|
|
53
56
|
bottom: 0,
|
|
54
57
|
py: 2,
|
|
@@ -26,7 +26,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
27
27
|
const Empty_1 = __importDefault(require("@arcblock/ux/lib/Empty"));
|
|
28
28
|
const RelativeTime_1 = __importDefault(require("@arcblock/ux/lib/RelativeTime"));
|
|
29
|
-
// import { useRuntimeState } from '@blocklet/pages-kit/builtin/async/ai-runtime';
|
|
30
29
|
const react_1 = require("@iconify/react");
|
|
31
30
|
const lab_1 = require("@mui/lab");
|
|
32
31
|
const material_1 = require("@mui/material");
|
|
@@ -37,6 +36,7 @@ const ActiveAgent_1 = require("../../contexts/ActiveAgent");
|
|
|
37
36
|
const CurrentAgent_1 = __importDefault(require("../../contexts/CurrentAgent"));
|
|
38
37
|
const CurrentMessage_1 = __importDefault(require("../../contexts/CurrentMessage"));
|
|
39
38
|
const use_appearances_1 = __importDefault(require("../../hooks/use-appearances"));
|
|
39
|
+
const runtime_1 = require("../../state/runtime");
|
|
40
40
|
const session_1 = require("../../state/session");
|
|
41
41
|
const CodePreview_1 = require("./components/CodePreview");
|
|
42
42
|
const ConfirmDialog_1 = __importDefault(require("./components/ConfirmDialog"));
|
|
@@ -96,9 +96,11 @@ function Page() {
|
|
|
96
96
|
}
|
|
97
97
|
exports.default = Page;
|
|
98
98
|
function V0ListRender() {
|
|
99
|
+
var _a, _b;
|
|
99
100
|
const ConfirmDialogRef = (0, react_2.useRef)();
|
|
100
101
|
const { sessions: sessionsList, setCurrentSessionId, loadLatestMessagesForAllSessions, sessionMap, deleteSession, loading, } = (0, session_1.useSessionState)((s) => s) || {};
|
|
101
102
|
const { isMobile } = (0, V0Runtime_1.useV0RuntimeContext)();
|
|
103
|
+
const { agent } = (0, runtime_1.useRuntimeState)();
|
|
102
104
|
const { t } = (0, locale_1.useLocaleContext)();
|
|
103
105
|
(0, react_2.useEffect)(() => {
|
|
104
106
|
const loadData = () => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -108,7 +110,7 @@ function V0ListRender() {
|
|
|
108
110
|
});
|
|
109
111
|
loadData();
|
|
110
112
|
}, [sessionsList === null || sessionsList === void 0 ? void 0 : sessionsList.length]);
|
|
111
|
-
return ((0, jsx_runtime_1.jsxs)(material_1.Box, { flex: 1, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h2", color: "textColor", sx: { fontWeight: 'bold', mt: isMobile ? 3 : 6 }, children: t('v0.title') }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h5", color: "textColor", sx: Object.assign(Object.assign({}, (0, utils_1.getLineClamp)(5)), { mt: 2 }), children: t('v0.description') }), loading ? ((0, jsx_runtime_1.jsx)(Loading_1.default, { sx: {
|
|
113
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Box, { flex: 1, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h2", color: "textColor", sx: { fontWeight: 'bold', mt: isMobile ? 3 : 6 }, children: ((_a = agent === null || agent === void 0 ? void 0 : agent.project) === null || _a === void 0 ? void 0 : _a.name) || t('v0.title') }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "h5", color: "textColor", sx: Object.assign(Object.assign({}, (0, utils_1.getLineClamp)(5)), { mt: 2 }), children: ((_b = agent === null || agent === void 0 ? void 0 : agent.project) === null || _b === void 0 ? void 0 : _b.description) || t('v0.description') }), loading ? ((0, jsx_runtime_1.jsx)(Loading_1.default, { sx: {
|
|
112
114
|
position: 'relative',
|
|
113
115
|
height: '40vh',
|
|
114
116
|
width: '100%',
|
|
@@ -117,7 +119,7 @@ function V0ListRender() {
|
|
|
117
119
|
display: 'flex',
|
|
118
120
|
alignContent: 'center',
|
|
119
121
|
justifyContent: 'center',
|
|
120
|
-
}, children: [(sessionsList === null || sessionsList === void 0 ? void 0 : sessionsList.length) ? ((0, jsx_runtime_1.jsx)(lab_1.Masonry, { columns: { xs: 1, sm: 2, md:
|
|
122
|
+
}, children: [(sessionsList === null || sessionsList === void 0 ? void 0 : sessionsList.length) ? ((0, jsx_runtime_1.jsx)(lab_1.Masonry, { columns: { xs: 1, sm: 2, md: 3, lg: 4 }, sequential: true, spacing: 2, children: sessionsList === null || sessionsList === void 0 ? void 0 : sessionsList.map((item) => {
|
|
121
123
|
var _a, _b;
|
|
122
124
|
const { name, id } = item;
|
|
123
125
|
const latestMessage = (_b = (_a = sessionMap === null || sessionMap === void 0 ? void 0 : sessionMap[id]) === null || _a === void 0 ? void 0 : _a.messages) === null || _b === void 0 ? void 0 : _b.at(-1);
|
|
@@ -177,11 +179,18 @@ function V0ListRender() {
|
|
|
177
179
|
}
|
|
178
180
|
function V0DetailRender() {
|
|
179
181
|
const { setCurrentSessionId } = (0, session_1.useSessionState)((s) => s) || {};
|
|
180
|
-
const { messages:
|
|
182
|
+
const { messages: messagesListOriginal, loading } = (0, session_1.useCurrentSessionState)((s) => s) || {};
|
|
181
183
|
const { currentMessageTaskId, setCurrentMessageTaskId, propertiesValueMap, isMobile } = (0, V0Runtime_1.useV0RuntimeContext)();
|
|
182
184
|
const [sliderOpenInMobile, setSliderOpenInMobile] = (0, react_2.useState)(!isMobile);
|
|
183
185
|
const { t } = (0, locale_1.useLocaleContext)();
|
|
184
|
-
|
|
186
|
+
// FIXME: 现在临时把 error 的消息隐藏了,后续需要优化
|
|
187
|
+
const messagesList = messagesListOriginal === null || messagesListOriginal === void 0 ? void 0 : messagesListOriginal.filter((message, index) => {
|
|
188
|
+
var _a, _b;
|
|
189
|
+
return (!(message === null || message === void 0 ? void 0 : message.error) && ((_b = (_a = message === null || message === void 0 ? void 0 : message.result) === null || _a === void 0 ? void 0 : _a.objects) === null || _b === void 0 ? void 0 : _b.length)) ||
|
|
190
|
+
message.taskId === currentMessageTaskId ||
|
|
191
|
+
index === messagesListOriginal.length - 1;
|
|
192
|
+
});
|
|
193
|
+
const currentMessage = messagesList === null || messagesList === void 0 ? void 0 : messagesList.find((message) => message.taskId === currentMessageTaskId);
|
|
185
194
|
(0, react_2.useEffect)(() => {
|
|
186
195
|
if (messagesList === null || messagesList === void 0 ? void 0 : messagesList.length) {
|
|
187
196
|
const latestMessage = messagesList === null || messagesList === void 0 ? void 0 : messagesList.at(-1);
|
|
@@ -241,7 +250,7 @@ function V0DetailRender() {
|
|
|
241
250
|
justifyContent: 'center',
|
|
242
251
|
flexDirection: 'column',
|
|
243
252
|
gap: 1,
|
|
244
|
-
}, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { onClick: () => {
|
|
253
|
+
}, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { id: taskId, onClick: () => {
|
|
245
254
|
// @ts-ignore
|
|
246
255
|
setCurrentMessageTaskId(item.taskId);
|
|
247
256
|
}, sx: Object.assign({ cursor: 'pointer', color: 'textColor', borderRadius: 1, border: 1, borderColor: isCurrent ? 'primary.main' : 'background.block', backgroundColor: 'white', position: 'relative', transition: 'all 0.3s', '&:hover': {
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
12
|
var t = {};
|
|
4
13
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -16,19 +25,74 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
16
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
26
|
exports.getCurrentCodeByTaskId = exports.CodeRenderByMessageMemo = exports.CodeRenderByMessage = exports.CodePreviewMemo = void 0;
|
|
18
27
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
28
|
+
const react_1 = require("@iconify/react");
|
|
19
29
|
const material_1 = require("@mui/material");
|
|
20
|
-
const
|
|
30
|
+
const react_2 = require("react");
|
|
21
31
|
const CustomComponentRenderer_1 = __importDefault(require("../../../../../../components/CustomComponentRenderer"));
|
|
22
32
|
const locale_1 = require("../../../../../locale");
|
|
33
|
+
const LoadingButton_1 = __importDefault(require("../../../components/LoadingButton"));
|
|
34
|
+
const CurrentAgent_1 = require("../../../contexts/CurrentAgent");
|
|
35
|
+
const runtime_1 = require("../../../state/runtime");
|
|
23
36
|
const MessageErrorView_1 = __importDefault(require("../../ChatOutput/MessageErrorView"));
|
|
37
|
+
const V0Runtime_1 = require("../contexts/V0Runtime");
|
|
24
38
|
const Loading_1 = require("./Loading");
|
|
39
|
+
const TransparentTooltip_1 = __importDefault(require("./TransparentTooltip"));
|
|
25
40
|
const codeField = 'code';
|
|
41
|
+
function RetryComponent({ message, tip }) {
|
|
42
|
+
const { t } = (0, locale_1.useLocaleContext)();
|
|
43
|
+
const { execute } = (0, runtime_1.useRuntimeState)();
|
|
44
|
+
const { aid } = (0, CurrentAgent_1.useCurrentAgent)();
|
|
45
|
+
const { setCurrentMessageTaskId } = (0, V0Runtime_1.useV0RuntimeContext)();
|
|
46
|
+
const [loading, setLoading] = (0, react_2.useState)(false);
|
|
47
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
48
|
+
width: '100%',
|
|
49
|
+
height: '100%',
|
|
50
|
+
display: 'flex',
|
|
51
|
+
flexDirection: 'column',
|
|
52
|
+
justifyContent: 'flex-start',
|
|
53
|
+
alignItems: 'center',
|
|
54
|
+
gap: 2,
|
|
55
|
+
p: 4,
|
|
56
|
+
}, children: [(0, jsx_runtime_1.jsx)(material_1.Box, { component: react_1.Icon, icon: "unjs:automd", sx: {
|
|
57
|
+
mt: 6,
|
|
58
|
+
fontSize: 120,
|
|
59
|
+
} }), (0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "h6", sx: {
|
|
60
|
+
display: 'flex',
|
|
61
|
+
alignItems: 'center',
|
|
62
|
+
}, children: [tip || t('v0.retryTip'), (0, jsx_runtime_1.jsx)(TransparentTooltip_1.default, { arrow: true, placement: "top", title: (0, jsx_runtime_1.jsx)(MessageErrorView_1.default, { error: (message === null || message === void 0 ? void 0 : message.error) || new Error('Empty response from AI or Code not found'), sx: {
|
|
63
|
+
mr: 0,
|
|
64
|
+
} }), children: (0, jsx_runtime_1.jsx)(material_1.Box, { component: react_1.Icon, icon: "akar-icons:info", sx: {
|
|
65
|
+
ml: 1,
|
|
66
|
+
} }) })] }), (0, jsx_runtime_1.jsx)(LoadingButton_1.default, { variant: "contained", loading: loading, color: "primary", onClick: () => __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
setLoading(true);
|
|
68
|
+
try {
|
|
69
|
+
const { parameters } = message || {};
|
|
70
|
+
// remove $ starting parameters object
|
|
71
|
+
const canUseParameters = Object.fromEntries(Object.entries(parameters || {}).filter(([key]) => !key.startsWith('$')));
|
|
72
|
+
yield execute({
|
|
73
|
+
aid,
|
|
74
|
+
parameters: canUseParameters,
|
|
75
|
+
onResponseStart: () => {
|
|
76
|
+
setCurrentMessageTaskId(undefined);
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
console.error(error);
|
|
82
|
+
}
|
|
83
|
+
finally {
|
|
84
|
+
setLoading(false);
|
|
85
|
+
}
|
|
86
|
+
}), children: t('v0.retry') })] }));
|
|
87
|
+
}
|
|
26
88
|
function CodePreview(_a) {
|
|
27
|
-
var { componentId = 'mock-dev-component', code, propertiesValue } = _a, restProps = __rest(_a, ["componentId", "code", "propertiesValue"]);
|
|
28
|
-
const { locale } = (0, locale_1.useLocaleContext)();
|
|
89
|
+
var { componentId = 'mock-dev-component', code, propertiesValue, message } = _a, restProps = __rest(_a, ["componentId", "code", "propertiesValue", "message"]);
|
|
90
|
+
const { t, locale } = (0, locale_1.useLocaleContext)();
|
|
29
91
|
if (!code)
|
|
30
92
|
return null;
|
|
31
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ id: componentId, className: "code-preview-wrapper" }, restProps, { children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: componentId, locale: locale, props: propertiesValue || {},
|
|
93
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ id: componentId, className: "code-preview-wrapper" }, restProps, { children: (0, jsx_runtime_1.jsx)(CustomComponentRenderer_1.default, { componentId: componentId, locale: locale, props: propertiesValue || {},
|
|
94
|
+
// eslint-disable-next-line react/no-unstable-nested-components
|
|
95
|
+
fallbackRender: () => (0, jsx_runtime_1.jsx)(RetryComponent, { message: message, tip: t('v0.errorCodeTip') }), dev: {
|
|
32
96
|
components: {
|
|
33
97
|
[componentId]: {
|
|
34
98
|
data: {
|
|
@@ -45,7 +109,7 @@ function CodePreview(_a) {
|
|
|
45
109
|
} }) }), componentId));
|
|
46
110
|
}
|
|
47
111
|
exports.default = CodePreview;
|
|
48
|
-
exports.CodePreviewMemo = (0,
|
|
112
|
+
exports.CodePreviewMemo = (0, react_2.memo)(CodePreview);
|
|
49
113
|
function CodeRenderByMessage({ zoom, message, minHeight = 200, sx, propertiesValueMap, }) {
|
|
50
114
|
var _a;
|
|
51
115
|
const { locale } = (0, locale_1.useLocaleContext)();
|
|
@@ -56,7 +120,7 @@ function CodeRenderByMessage({ zoom, message, minHeight = 200, sx, propertiesVal
|
|
|
56
120
|
},
|
|
57
121
|
};
|
|
58
122
|
const isMessageLoading = ((message === null || message === void 0 ? void 0 : message.loading) || !(message === null || message === void 0 ? void 0 : message.result)) && !(message === null || message === void 0 ? void 0 : message.error);
|
|
59
|
-
const ContentRender = (0,
|
|
123
|
+
const ContentRender = (0, react_2.useCallback)(() => {
|
|
60
124
|
var _a, _b, _c, _d;
|
|
61
125
|
if (isMessageLoading) {
|
|
62
126
|
return ((0, jsx_runtime_1.jsx)(material_1.Box, { className: "code-message-loading", sx: {
|
|
@@ -66,24 +130,15 @@ function CodeRenderByMessage({ zoom, message, minHeight = 200, sx, propertiesVal
|
|
|
66
130
|
alignItems: 'center',
|
|
67
131
|
}, children: (0, jsx_runtime_1.jsx)(Loading_1.AIRunningLoading, {}) }));
|
|
68
132
|
}
|
|
69
|
-
if (message === null || message === void 0 ? void 0 : message.error) {
|
|
70
|
-
return (
|
|
71
|
-
width: '100%',
|
|
72
|
-
}, children: (0, jsx_runtime_1.jsx)(MessageErrorView_1.default, { error: message.error, sx: {
|
|
73
|
-
mr: 0,
|
|
74
|
-
} }) }));
|
|
75
|
-
}
|
|
76
|
-
if (!((_b = (_a = message === null || message === void 0 ? void 0 : message.result) === null || _a === void 0 ? void 0 : _a.objects) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
77
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsx)(MessageErrorView_1.default, { error: new Error('Something error'), sx: {
|
|
78
|
-
mr: 0,
|
|
79
|
-
} }) }));
|
|
133
|
+
if ((message === null || message === void 0 ? void 0 : message.error) || !((_b = (_a = message === null || message === void 0 ? void 0 : message.result) === null || _a === void 0 ? void 0 : _a.objects) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
134
|
+
return (0, jsx_runtime_1.jsx)(RetryComponent, { message: message });
|
|
80
135
|
}
|
|
81
136
|
return (_d = (_c = message === null || message === void 0 ? void 0 : message.result) === null || _c === void 0 ? void 0 : _c.objects) === null || _d === void 0 ? void 0 : _d.map((item) => {
|
|
82
137
|
var _a, _b, _c;
|
|
83
138
|
const { taskId } = item;
|
|
84
139
|
// @ts-ignore
|
|
85
140
|
const code = (_a = item === null || item === void 0 ? void 0 : item.data) === null || _a === void 0 ? void 0 : _a[codeField];
|
|
86
|
-
return ((0, jsx_runtime_1.jsx)(exports.CodePreviewMemo, { componentId: `code-preview-${taskId}`, code: code, propertiesValue: ((_b = propertiesValueMap === null || propertiesValueMap === void 0 ? void 0 : propertiesValueMap[taskId]) === null || _b === void 0 ? void 0 : _b[locale]) || ((_c = propertiesValueMap === null || propertiesValueMap === void 0 ? void 0 : propertiesValueMap[taskId]) === null || _c === void 0 ? void 0 : _c.en) || {} }, item.taskId));
|
|
141
|
+
return ((0, jsx_runtime_1.jsx)(exports.CodePreviewMemo, { componentId: `code-preview-${taskId}`, code: code, propertiesValue: ((_b = propertiesValueMap === null || propertiesValueMap === void 0 ? void 0 : propertiesValueMap[taskId]) === null || _b === void 0 ? void 0 : _b[locale]) || ((_c = propertiesValueMap === null || propertiesValueMap === void 0 ? void 0 : propertiesValueMap[taskId]) === null || _c === void 0 ? void 0 : _c.en) || {}, message: message }, item.taskId));
|
|
87
142
|
});
|
|
88
143
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
89
144
|
}, [isMessageLoading, (_a = message === null || message === void 0 ? void 0 : message.result) === null || _a === void 0 ? void 0 : _a.objects, propertiesValueMap, locale]);
|
|
@@ -92,7 +147,7 @@ function CodeRenderByMessage({ zoom, message, minHeight = 200, sx, propertiesVal
|
|
|
92
147
|
} }), children: (0, jsx_runtime_1.jsx)(ContentRender, {}) }, message === null || message === void 0 ? void 0 : message.taskId));
|
|
93
148
|
}
|
|
94
149
|
exports.CodeRenderByMessage = CodeRenderByMessage;
|
|
95
|
-
exports.CodeRenderByMessageMemo = (0,
|
|
150
|
+
exports.CodeRenderByMessageMemo = (0, react_2.memo)(CodeRenderByMessage);
|
|
96
151
|
function getCurrentCodeByTaskId(message, taskId) {
|
|
97
152
|
var _a, _b, _c, _d;
|
|
98
153
|
// @ts-ignore
|
package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/components/TransparentTooltip.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
15
|
+
const material_1 = require("@mui/material");
|
|
16
|
+
const TransparentTooltip = (0, material_1.styled)((_a) => {
|
|
17
|
+
var { className } = _a, props = __rest(_a, ["className"]);
|
|
18
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({}, props, { classes: { popper: className } })));
|
|
19
|
+
})(() => ({
|
|
20
|
+
[`& .${material_1.tooltipClasses.tooltip}`]: {
|
|
21
|
+
backgroundColor: 'transparent',
|
|
22
|
+
boxShadow: 'none',
|
|
23
|
+
},
|
|
24
|
+
}));
|
|
25
|
+
exports.default = TransparentTooltip;
|
|
@@ -54,9 +54,14 @@ function UserQuestion({ question }) {
|
|
|
54
54
|
backgroundColor: 'grey.200',
|
|
55
55
|
maxWidth: 300,
|
|
56
56
|
}, children: (0, jsx_runtime_1.jsx)(ClickToCopy_1.CopyButton, { locale: locale, unstyled: true, render: ({ copyButton, containerRef }) => {
|
|
57
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Box, { ref: containerRef, display: "flex", alignItems: "center", sx: Object.assign(Object.assign({}, BASE_QUESTION_SX), { color: 'textColor' }), children: (0, jsx_runtime_1.jsx)(ClickToCopy_1.default, { locale: locale, unstyled: true, disableHoverListener: true, disableFocusListener: true, disableTouchListener: true, children: (0, jsx_runtime_1.jsx)(material_1.Tooltip, { placement: "bottom", arrow: true, title: (0, jsx_runtime_1.
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Box, { ref: containerRef, display: "flex", alignItems: "center", sx: Object.assign(Object.assign({}, BASE_QUESTION_SX), { color: 'textColor' }), children: (0, jsx_runtime_1.jsx)(ClickToCopy_1.default, { locale: locale, unstyled: true, disableHoverListener: true, disableFocusListener: true, disableTouchListener: true, children: (0, jsx_runtime_1.jsx)(material_1.Tooltip, { placement: "bottom", arrow: true, title: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
58
|
+
display: 'flex',
|
|
59
|
+
alignItems: 'center',
|
|
60
|
+
}, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { sx: Object.assign(Object.assign({}, BASE_QUESTION_SX), { lineHeight: 1, color: 'white' }), children: question }), (0, jsx_runtime_1.jsx)(material_1.Box, { id: "copy-button-wrapper", component: "span", sx: {
|
|
61
|
+
ml: 0.5,
|
|
62
|
+
mt: 0.25,
|
|
63
|
+
fontSize: 14,
|
|
64
|
+
}, children: copyButton })] }), children: (0, jsx_runtime_1.jsx)(material_1.Typography, { sx: Object.assign(Object.assign(Object.assign({}, BASE_QUESTION_SX), { textAlign: 'left', alignItems: 'center' }), (0, utils_1.getLineClamp)(1)), children: question }) }) }) }));
|
|
60
65
|
} }) })] }));
|
|
61
66
|
}
|
|
62
67
|
exports.default = UserQuestion;
|
|
@@ -42,7 +42,7 @@ function CustomComponentRenderer(_a) {
|
|
|
42
42
|
var { dev } = _a, props = __rest(_a, ["dev"]);
|
|
43
43
|
const inheritedDev = (0, DevProvider_1.useDev)();
|
|
44
44
|
const BuiltinComponent = BuiltinComponents[props.componentId];
|
|
45
|
-
return ((0, jsx_runtime_1.jsx)(react_error_boundary_1.ErrorBoundary, { fallbackRender: ErrorView, resetKeys: [Date.now()], children: (0, jsx_runtime_1.jsx)(DevProvider_1.DevProvider, { dev: dev !== null && dev !== void 0 ? dev : inheritedDev, children: BuiltinComponent ? ((0, jsx_runtime_1.jsx)(BuiltinComponent, Object.assign({}, props))) : ((0, jsx_runtime_1.jsx)(ComponentRenderer, Object.assign({}, props, { instanceId: (_b = props.instanceId) !== null && _b !== void 0 ? _b : props.componentId }))) }) }));
|
|
45
|
+
return ((0, jsx_runtime_1.jsx)(react_error_boundary_1.ErrorBoundary, { fallbackRender: (props === null || props === void 0 ? void 0 : props.fallbackRender) || ErrorView, resetKeys: [Date.now()], children: (0, jsx_runtime_1.jsx)(DevProvider_1.DevProvider, { dev: dev !== null && dev !== void 0 ? dev : inheritedDev, children: BuiltinComponent ? ((0, jsx_runtime_1.jsx)(BuiltinComponent, Object.assign({}, props))) : ((0, jsx_runtime_1.jsx)(ComponentRenderer, Object.assign({}, props, { instanceId: (_b = props.instanceId) !== null && _b !== void 0 ? _b : props.componentId }))) }) }));
|
|
46
46
|
}
|
|
47
47
|
exports.default = CustomComponentRenderer;
|
|
48
48
|
const BuiltinComponents = {
|
|
@@ -59,7 +59,8 @@ function ComponentRenderer(_a) {
|
|
|
59
59
|
}
|
|
60
60
|
const component = (0, state_1.useComponent)(Object.assign(Object.assign({}, props), { dev }));
|
|
61
61
|
if (component === null || component === void 0 ? void 0 : component.error) {
|
|
62
|
-
|
|
62
|
+
// throw to outer error boundary
|
|
63
|
+
throw component.error;
|
|
63
64
|
}
|
|
64
65
|
if (component === null || component === void 0 ? void 0 : component.Component) {
|
|
65
66
|
return ((0, jsx_runtime_1.jsx)(Renderer, Object.assign({ renderCount: renderCount + 1 }, props, { Component: component.Component, props: Object.assign(Object.assign({}, component.props), props.props) })));
|
|
@@ -150,7 +150,7 @@ function useComponent({ instanceId, componentId, properties, locale, dev }) {
|
|
|
150
150
|
const preload = usePreloadComponent({ instanceId, componentId, properties, locale, dev });
|
|
151
151
|
return {
|
|
152
152
|
Component: (_a = transpile === null || transpile === void 0 ? void 0 : transpile.Component) !== null && _a !== void 0 ? _a : preload === null || preload === void 0 ? void 0 : preload.Component,
|
|
153
|
-
props: (_b =
|
|
153
|
+
props: (_b = transpile === null || transpile === void 0 ? void 0 : transpile.props) !== null && _b !== void 0 ? _b : preload === null || preload === void 0 ? void 0 : preload.props,
|
|
154
154
|
error: transpile === null || transpile === void 0 ? void 0 : transpile.error,
|
|
155
155
|
};
|
|
156
156
|
}
|