@blocklet/pages-kit 0.2.356 → 0.2.358

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.
@@ -21,23 +21,14 @@ const material_1 = require("@mui/material");
21
21
  const react_1 = require("react");
22
22
  const react_helmet_1 = require("react-helmet");
23
23
  const runtime_1 = require("../state/runtime");
24
+ const fonts_1 = require("../utils/fonts");
24
25
  const GlobalLoading_1 = __importDefault(require("./GlobalLoading"));
25
- const getFontUrl = (fontList) => {
26
- var _a;
27
- if (!fontList.length)
28
- return;
29
- const BASE_URL = 'https://fonts.googleapis.com/css?family=';
30
- const newFontList = (_a = fontList
31
- .filter((font) => typeof font === 'string')) === null || _a === void 0 ? void 0 : _a.map((font) => font.replace(/ /g, '+')).join('|');
32
- // eslint-disable-next-line consistent-return
33
- return `${BASE_URL}${newFontList}`;
34
- };
35
26
  function ThemeProvider({ children }) {
36
27
  var _a, _b, _c;
37
28
  const { appearance } = (0, runtime_1.useRuntimeState)().agent.project;
38
29
  const theme = (0, material_1.useTheme)();
39
- const titleFont = (_a = appearance === null || appearance === void 0 ? void 0 : appearance.typography) === null || _a === void 0 ? void 0 : _a.fontFamily;
40
- const headFont = (_c = (_b = appearance === null || appearance === void 0 ? void 0 : appearance.typography) === null || _b === void 0 ? void 0 : _b.heading) === null || _c === void 0 ? void 0 : _c.fontFamily;
30
+ const bodyFontFamily = (_a = appearance === null || appearance === void 0 ? void 0 : appearance.typography) === null || _a === void 0 ? void 0 : _a.fontFamily;
31
+ const headingFontFamily = (_c = (_b = appearance === null || appearance === void 0 ? void 0 : appearance.typography) === null || _b === void 0 ? void 0 : _b.heading) === null || _c === void 0 ? void 0 : _c.fontFamily;
41
32
  const newTheme = (0, react_1.useMemo)(() => {
42
33
  var _a, _b, _c, _d, _e, _f;
43
34
  let { primary } = theme.palette;
@@ -164,7 +155,17 @@ function ThemeProvider({ children }) {
164
155
  ],
165
156
  });
166
157
  }, [theme]);
167
- return ((0, jsx_runtime_1.jsxs)(material_1.ThemeProvider, { theme: newTheme, children: [(0, jsx_runtime_1.jsx)(react_helmet_1.Helmet, { children: (0, jsx_runtime_1.jsx)("link", { rel: "stylesheet", href: getFontUrl([titleFont, headFont]) }) }), (0, jsx_runtime_1.jsxs)(material_1.CssBaseline, { children: [(0, jsx_runtime_1.jsx)(material_1.GlobalStyles, { styles: (theme) => theme.unstable_sx({
158
+ const fontUrls = (0, react_1.useMemo)(() => {
159
+ const urls = [bodyFontFamily, headingFontFamily]
160
+ .filter((i) => !!i)
161
+ .map((font) => {
162
+ var _a;
163
+ return ((_a = fonts_1.chineseFonts.find((i) => i.value === font)) === null || _a === void 0 ? void 0 : _a.link) ||
164
+ `https://fonts.googleapis.com/css?family=${font.replace(/ /g, '+')}`;
165
+ });
166
+ return [...new Set(urls)];
167
+ }, [bodyFontFamily, headingFontFamily]);
168
+ return ((0, jsx_runtime_1.jsxs)(material_1.ThemeProvider, { theme: newTheme, children: [(0, jsx_runtime_1.jsx)(react_helmet_1.Helmet, { children: fontUrls.map((url) => ((0, jsx_runtime_1.jsx)("link", { rel: "stylesheet", href: url }, url))) }), (0, jsx_runtime_1.jsxs)(material_1.CssBaseline, { children: [(0, jsx_runtime_1.jsx)(material_1.GlobalStyles, { styles: (theme) => theme.unstable_sx({
168
169
  'h1,h2,h3,h4,h5': {
169
170
  fontFamily: `${theme.typography.h1.fontFamily} !important`,
170
171
  },
@@ -43,16 +43,9 @@ function PhotoGalleryItem() {
43
43
  const { message } = (0, CurrentMessage_1.useCurrentMessage)();
44
44
  const [openDialog, setOpenDialog] = (0, react_2.useState)(false);
45
45
  const objects = (_b = (_a = message.outputs) === null || _a === void 0 ? void 0 : _a.objects) !== null && _b !== void 0 ? _b : [];
46
- const images = objects.flatMap((i) => { var _a, _b; return (_b = (_a = i.data) === null || _a === void 0 ? void 0 : _a[types_1.RuntimeOutputVariable.images]) !== null && _b !== void 0 ? _b : []; });
47
- if (!images.length && message.error) {
48
- return ((0, jsx_runtime_1.jsx)(material_1.Stack, { alignItems: "center", justifyContent: "center", sx: {
49
- aspectRatio: 1,
50
- bgcolor: 'grey.50',
51
- borderRadius: 1,
52
- overflow: 'hidden',
53
- wordBreak: 'break-word',
54
- }, children: (0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "error", sx: { bgcolor: 'transparent' }, children: message.error.message }) }));
55
- }
46
+ const images = objects.flatMap((i) => { var _a; return (_a = i === null || i === void 0 ? void 0 : i[types_1.RuntimeOutputVariable.images]) !== null && _a !== void 0 ? _a : []; });
47
+ if (!images.length && message.error)
48
+ throw message.error;
56
49
  return images.map(({ url }, index) => {
57
50
  var _a;
58
51
  return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
@@ -28,11 +28,13 @@ exports.default = CodePreview;
28
28
  exports.CodeRenderByMessage = CodeRenderByMessage;
29
29
  exports.getCurrentCodeByTaskId = getCurrentCodeByTaskId;
30
30
  const jsx_runtime_1 = require("react/jsx-runtime");
31
+ const api_1 = require("@blocklet/ai-kit/api");
31
32
  const react_1 = require("@iconify/react");
32
33
  const material_1 = require("@mui/material");
33
34
  const react_2 = require("react");
34
35
  const CustomComponentRenderer_1 = __importDefault(require("../../../../../../components/CustomComponentRenderer"));
35
36
  const locale_1 = require("../../../../../locale");
37
+ const AgentErrorBoundary_1 = require("../../../components/AgentErrorBoundary");
36
38
  const LoadingButton_1 = __importDefault(require("../../../components/LoadingButton"));
37
39
  const CurrentAgent_1 = require("../../../contexts/CurrentAgent");
38
40
  const runtime_1 = require("../../../state/runtime");
@@ -42,6 +44,7 @@ const Loading_1 = require("./Loading");
42
44
  const TransparentTooltip_1 = __importDefault(require("./TransparentTooltip"));
43
45
  const codeField = 'code';
44
46
  function RetryComponent({ message, tip }) {
47
+ var _a;
45
48
  const { t } = (0, locale_1.useLocaleContext)();
46
49
  const { execute } = (0, runtime_1.useRuntimeState)();
47
50
  const { aid } = (0, CurrentAgent_1.useCurrentAgent)();
@@ -59,14 +62,14 @@ function RetryComponent({ message, tip }) {
59
62
  }, children: [(0, jsx_runtime_1.jsx)(material_1.Box, { component: react_1.Icon, icon: "unjs:automd", sx: {
60
63
  mt: 6,
61
64
  fontSize: 120,
62
- } }), (0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "h6", sx: {
65
+ } }), ((_a = message === null || message === void 0 ? void 0 : message.error) === null || _a === void 0 ? void 0 : _a.type) === api_1.SubscriptionErrorType.UNSUBSCRIBED ? ((0, jsx_runtime_1.jsx)(material_1.Box, { width: "100%", children: (0, jsx_runtime_1.jsx)(AgentErrorBoundary_1.AgentErrorView, { error: message.error }) })) : ((0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "h6", sx: {
63
66
  display: 'flex',
64
67
  alignItems: 'center',
65
68
  }, 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('Code syntax errors'), sx: {
66
69
  mr: 0,
67
70
  } }), children: (0, jsx_runtime_1.jsx)(material_1.Box, { component: react_1.Icon, icon: "akar-icons:info", sx: {
68
71
  ml: 1,
69
- } }) })] }), (0, jsx_runtime_1.jsx)(LoadingButton_1.default, { variant: "contained", loading: loading, color: "primary", onClick: () => __awaiter(this, void 0, void 0, function* () {
72
+ } }) })] })), (0, jsx_runtime_1.jsx)(LoadingButton_1.default, { variant: "contained", loading: loading, color: "primary", onClick: () => __awaiter(this, void 0, void 0, function* () {
70
73
  setLoading(true);
71
74
  try {
72
75
  const { inputs } = message || {};
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.chineseFonts = void 0;
4
+ exports.chineseFonts = [
5
+ {
6
+ key: '东方大楷',
7
+ value: 'Alimama DongFangDaKai',
8
+ link: 'https://cdn.jsdelivr.net/npm/cn-fontsource-alimama-dong-fang-da-kai-regular/font.css',
9
+ },
10
+ {
11
+ key: '鸿雷行书',
12
+ value: 'hongleixingshu',
13
+ link: 'https://cdn.jsdelivr.net/npm/cn-fontsource-hongleixingshu-regular/font.css',
14
+ },
15
+ {
16
+ key: '方正楷体',
17
+ value: 'FZKai-Z03',
18
+ link: 'https://cdn.jsdelivr.net/npm/cn-fontsource-fz-kai-z-03-regular/font.css',
19
+ },
20
+ {
21
+ key: '方正宋体',
22
+ value: 'FZShuSong-Z01',
23
+ link: 'https://cdn.jsdelivr.net/npm/cn-fontsource-fz-shu-song-z-01-regular/font.css',
24
+ },
25
+ {
26
+ key: '方正黑体',
27
+ value: 'FZHei-B01',
28
+ link: 'https://cdn.jsdelivr.net/npm/cn-fontsource-fz-hei-b-01-regular/font.css',
29
+ },
30
+ {
31
+ key: '方正仿宋',
32
+ value: 'FZFangSong-Z02S',
33
+ link: 'https://cdn.jsdelivr.net/npm/cn-fontsource-fz-fang-song-z-02-s-regular/font.css',
34
+ },
35
+ ];