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