@blocklet/pages-kit 0.2.321 → 0.2.322

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 (23) hide show
  1. package/lib/cjs/builtin/async/ai-runtime/components/RuntimeCommonProvider.js +1 -4
  2. package/lib/cjs/builtin/async/ai-runtime/components/ThemeProvider.js +21 -54
  3. package/lib/cjs/builtin/async/ai-runtime/runtime/ChatBotButton/index.js +2 -1
  4. package/lib/cjs/builtin/async/ai-runtime/runtime/Runtime/index.js +2 -1
  5. package/lib/cjs/builtin/async/ai-runtime/runtime-components/PhotoGallery/index.js +2 -20
  6. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/index.js +2 -20
  7. package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimplePage/index.js +2 -20
  8. package/lib/cjs/tsconfig.tsbuildinfo +1 -1
  9. package/lib/esm/builtin/async/ai-runtime/components/RuntimeCommonProvider.js +2 -5
  10. package/lib/esm/builtin/async/ai-runtime/components/ThemeProvider.js +20 -56
  11. package/lib/esm/builtin/async/ai-runtime/runtime/ChatBotButton/index.js +2 -1
  12. package/lib/esm/builtin/async/ai-runtime/runtime/Runtime/index.js +2 -1
  13. package/lib/esm/builtin/async/ai-runtime/runtime-components/PhotoGallery/index.js +4 -22
  14. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimpleChat/index.js +4 -22
  15. package/lib/esm/builtin/async/ai-runtime/runtime-components/SimplePage/index.js +4 -22
  16. package/lib/esm/tsconfig.tsbuildinfo +1 -1
  17. package/lib/types/builtin/async/ai-runtime/api/agent.d.ts +1 -0
  18. package/lib/types/builtin/async/ai-runtime/components/ThemeProvider.d.ts +1 -3
  19. package/lib/types/builtin/async/ai-runtime/runtime-components/PhotoGallery/index.d.ts +1 -2
  20. package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/index.d.ts +1 -2
  21. package/lib/types/builtin/async/ai-runtime/runtime-components/SimplePage/index.d.ts +1 -2
  22. package/lib/types/tsconfig.tsbuildinfo +1 -1
  23. package/package.json +1 -1
@@ -5,16 +5,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.RuntimeLocaleProvider = void 0;
7
7
  const jsx_runtime_1 = require("react/jsx-runtime");
8
- const material_1 = require("@mui/material");
9
8
  const react_1 = __importDefault(require("react"));
10
9
  const react_error_boundary_1 = require("react-error-boundary");
11
10
  const ux_1 = require("../../../arcblock/ux");
12
11
  const locale_1 = require("../../../locale");
13
12
  const locales_1 = require("../locales");
14
- const GlobalLoading_1 = __importDefault(require("./GlobalLoading"));
15
- const ThemeProvider_1 = __importDefault(require("./ThemeProvider"));
16
13
  function RuntimeCommonProvider({ children }) {
17
- return ((0, jsx_runtime_1.jsx)(RuntimeLocaleProvider, { children: (0, jsx_runtime_1.jsx)(ThemeProvider_1.default, { children: (0, jsx_runtime_1.jsxs)(react_error_boundary_1.ErrorBoundary, { FallbackComponent: ErrorRender, children: [(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.default.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 })] }) }) }));
14
+ return ((0, jsx_runtime_1.jsx)(RuntimeLocaleProvider, { children: (0, jsx_runtime_1.jsx)(react_error_boundary_1.ErrorBoundary, { FallbackComponent: ErrorRender, children: (0, jsx_runtime_1.jsx)(react_1.default.Suspense, { children: children }) }) }));
18
15
  }
19
16
  exports.default = RuntimeCommonProvider;
20
17
  function ErrorRender({ error }) {
@@ -10,38 +10,29 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  }
11
11
  return t;
12
12
  };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
13
16
  Object.defineProperty(exports, "__esModule", { value: true });
14
17
  const jsx_runtime_1 = require("react/jsx-runtime");
15
18
  const icons_material_1 = require("@mui/icons-material");
16
19
  const material_1 = require("@mui/material");
17
20
  const react_1 = require("react");
18
- function ThemeProvider({ children, template, transparentHeaderBg, }) {
21
+ const runtime_1 = require("../state/runtime");
22
+ const GlobalLoading_1 = __importDefault(require("./GlobalLoading"));
23
+ function ThemeProvider({ children }) {
24
+ const { primaryColor } = (0, runtime_1.useRuntimeState)().agent.project;
19
25
  const theme = (0, material_1.useTheme)();
20
- const colors = {
21
- default: {
22
- color: undefined,
23
- bg: '#ffffff',
24
- // primary: '#333843',
25
- primary: '#3B82F6',
26
- },
27
- blue: {
28
- color: 'white',
29
- bg: 'linear-gradient(180deg, #0D60FF 0%, #E2EDFE 100%)',
30
- primary: '#0D60FF',
31
- },
32
- red: {
33
- color: 'white',
34
- bg: 'linear-gradient(180deg, #F65F84 0%, #817DE6 100%), linear-gradient(180deg, #9300FF 0%, #D900FF 100%)',
35
- primary: '#F65F84',
36
- },
37
- green: {
38
- color: 'white',
39
- bg: 'linear-gradient(180deg, #149E8C 0%, #35E77D 100%)',
40
- primary: '#149E8C',
41
- },
42
- };
43
- const color = colors[template] || colors.default;
44
26
  const newTheme = (0, react_1.useMemo)(() => {
27
+ let { primary } = theme.palette;
28
+ try {
29
+ if (primaryColor) {
30
+ primary = theme.palette.augmentColor({ color: { main: primaryColor } });
31
+ }
32
+ }
33
+ catch (error) {
34
+ console.error('augment primary color error', { error });
35
+ }
45
36
  const themeOptions = {
46
37
  components: {
47
38
  MuiSelect: {
@@ -109,9 +100,7 @@ function ThemeProvider({ children, template, transparentHeaderBg, }) {
109
100
  };
110
101
  const paletteTheme = (0, material_1.createTheme)({
111
102
  palette: {
112
- primary: {
113
- main: color.primary,
114
- },
103
+ primary,
115
104
  secondary: {
116
105
  main: '#010714',
117
106
  },
@@ -134,7 +123,7 @@ function ThemeProvider({ children, template, transparentHeaderBg, }) {
134
123
  // @ts-ignore
135
124
  black: paletteTheme.palette.black,
136
125
  background: {
137
- default: color.bg,
126
+ default: '#ffffff',
138
127
  },
139
128
  },
140
129
  shape: {
@@ -149,30 +138,8 @@ function ThemeProvider({ children, template, transparentHeaderBg, }) {
149
138
  });
150
139
  }, [theme]);
151
140
  return ((0, jsx_runtime_1.jsxs)(material_1.ThemeProvider, { theme: newTheme, children: [(0, jsx_runtime_1.jsx)(material_1.GlobalStyles, { styles: {
152
- '.page-header': transparentHeaderBg
153
- ? {
154
- backgroundColor: 'transparent !important',
155
- color: color.color,
156
- button: {
157
- color: color.color,
158
- },
159
- }
160
- : {
161
- // with border bottom
162
- borderBottom: '1px solid rgba(229, 231, 235, 1)',
163
- },
164
- body: {
165
- background: 'transparent !important',
166
- '&:before': {
167
- content: '""',
168
- position: 'fixed',
169
- left: 0,
170
- top: 0,
171
- right: 0,
172
- bottom: 0,
173
- background: color.bg,
174
- zIndex: -1,
175
- },
141
+ '.page-header': {
142
+ borderBottom: '1px solid rgba(229, 231, 235, 1)',
176
143
  },
177
144
  '.white-tooltip .MuiTooltip-tooltip': {
178
145
  background: 'white !important',
@@ -180,6 +147,6 @@ function ThemeProvider({ children, template, transparentHeaderBg, }) {
180
147
  border: '1px solid rgba(229, 231, 235, 1)',
181
148
  padding: 4,
182
149
  },
183
- } }), children] }));
150
+ } }), (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 })] }));
184
151
  }
185
152
  exports.default = ThemeProvider;
@@ -47,6 +47,7 @@ const PopperMenuButton_1 = __importDefault(require("../../components/PopperMenuB
47
47
  const LoadingMenuItem_1 = __importDefault(require("../../components/PopperMenuButton/LoadingMenuItem"));
48
48
  const RuntimeCommonProvider_1 = __importDefault(require("../../components/RuntimeCommonProvider"));
49
49
  const ScrollView_1 = __importDefault(require("../../components/ScrollView"));
50
+ const ThemeProvider_1 = __importDefault(require("../../components/ThemeProvider"));
50
51
  const constants_1 = require("../../constants");
51
52
  const ActiveAgent_1 = __importDefault(require("../../contexts/ActiveAgent"));
52
53
  const Runtime_1 = __importDefault(require("../../contexts/Runtime"));
@@ -54,7 +55,7 @@ const use_appearances_1 = __importStar(require("../../hooks/use-appearances"));
54
55
  const runtime_1 = require("../../state/runtime");
55
56
  const session_1 = require("../../state/session");
56
57
  function ChatBotButton({ aid, working }) {
57
- return ((0, jsx_runtime_1.jsx)(RuntimeCommonProvider_1.default, { children: (0, jsx_runtime_1.jsx)(Runtime_1.default, { aid: aid, working: working, children: (0, jsx_runtime_1.jsx)(ActiveAgent_1.default, { children: (0, jsx_runtime_1.jsx)(ChatBotContent, {}) }) }) }));
58
+ return ((0, jsx_runtime_1.jsx)(RuntimeCommonProvider_1.default, { children: (0, jsx_runtime_1.jsx)(Runtime_1.default, { aid: aid, working: working, children: (0, jsx_runtime_1.jsx)(ThemeProvider_1.default, { children: (0, jsx_runtime_1.jsx)(ActiveAgent_1.default, { children: (0, jsx_runtime_1.jsx)(ChatBotContent, {}) }) }) }) }));
58
59
  }
59
60
  exports.default = ChatBotButton;
60
61
  function ChatBotContent() {
@@ -37,6 +37,7 @@ const header_1 = require("../../../../page/header");
37
37
  const utils_1 = require("../../../../utils");
38
38
  const RuntimeCommonProvider_1 = __importStar(require("../../components/RuntimeCommonProvider"));
39
39
  const SocialShare_1 = __importDefault(require("../../components/SocialShare"));
40
+ const ThemeProvider_1 = __importDefault(require("../../components/ThemeProvider"));
40
41
  const constants_1 = require("../../constants");
41
42
  const ActiveAgent_1 = __importDefault(require("../../contexts/ActiveAgent"));
42
43
  const Runtime_1 = __importStar(require("../../contexts/Runtime"));
@@ -48,7 +49,7 @@ function AgentCreatedBy({ did }) {
48
49
  return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [t('by'), " ", (0, jsx_runtime_1.jsx)(material_1.Box, { component: ux_1.DID, did: did, copyable: false, responsive: true })] }));
49
50
  }
50
51
  function Runtime({ aid, working }) {
51
- const children = ((0, jsx_runtime_1.jsx)(ActiveAgent_1.default, { children: (0, jsx_runtime_1.jsx)(RuntimeView, {}) }));
52
+ const children = ((0, jsx_runtime_1.jsx)(ThemeProvider_1.default, { children: (0, jsx_runtime_1.jsx)(ActiveAgent_1.default, { children: (0, jsx_runtime_1.jsx)(RuntimeView, {}) }) }));
52
53
  return ((0, jsx_runtime_1.jsx)(RuntimeCommonProvider_1.default, { children: aid ? ((0, jsx_runtime_1.jsx)(Runtime_1.default, { aid: aid, working: working, children: children })) : ((0, jsx_runtime_1.jsx)(Runtime_1.RuntimeProviderFromUrl, { children: children })) }));
53
54
  }
54
55
  exports.default = Runtime;
@@ -29,28 +29,10 @@ const CurrentMessage_1 = __importDefault(require("../../contexts/CurrentMessage"
29
29
  const use_appearances_1 = __importDefault(require("../../hooks/use-appearances"));
30
30
  const session_1 = require("../../state/session");
31
31
  const map_right_1 = __importDefault(require("../../utils/map-right"));
32
- function PhotoGallery({ resultTitle, primaryColor }) {
32
+ function PhotoGallery({ resultTitle }) {
33
33
  const { activeAgentId } = (0, ActiveAgent_1.useActiveAgent)();
34
34
  (0, session_1.useAutoLoadSessionState)();
35
- const inheritedTheme = (0, material_1.useTheme)();
36
- const theme = (0, react_1.useMemo)(() => {
37
- let { primary } = inheritedTheme.palette;
38
- try {
39
- if (primaryColor) {
40
- primary = inheritedTheme.palette.augmentColor({ color: { main: primaryColor } });
41
- }
42
- }
43
- catch (error) {
44
- console.error('augment primary color error', { error });
45
- }
46
- return (0, material_1.createTheme)(inheritedTheme, {
47
- palette: { primary },
48
- shape: {
49
- borderRadius: 8,
50
- },
51
- });
52
- }, [inheritedTheme, primaryColor]);
53
- return ((0, jsx_runtime_1.jsx)(material_1.ThemeProvider, { theme: theme, children: (0, jsx_runtime_1.jsxs)(material_1.Stack, { className: "aigne-layout aigne-photo-wall-layout", children: [(0, jsx_runtime_1.jsx)(SimpleHeader_1.default, { TitleProps: { fontSize: 48 }, DescriptionProps: { fontSize: 20 }, maxWidth: "md", mx: "auto", width: "100%", px: { xs: 2, sm: 3 } }), (0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: activeAgentId, children: (0, jsx_runtime_1.jsx)(AgentInputRender, { className: "aigne-inputs aigne-photo-wall-inputs", maxWidth: "md", mx: "auto", width: "100%", px: { xs: 2, sm: 3 } }) }), (0, jsx_runtime_1.jsx)(OutputView, { resultTitle: resultTitle, className: "aigne-outputs aigne-photo-wall-outputs", gap: 2 })] }) }));
35
+ return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { className: "aigne-layout aigne-photo-wall-layout", children: [(0, jsx_runtime_1.jsx)(SimpleHeader_1.default, { TitleProps: { fontSize: 48 }, DescriptionProps: { fontSize: 20 }, maxWidth: "md", mx: "auto", width: "100%", px: { xs: 2, sm: 3 } }), (0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: activeAgentId, children: (0, jsx_runtime_1.jsx)(AgentInputRender, { className: "aigne-inputs aigne-photo-wall-inputs", maxWidth: "md", mx: "auto", width: "100%", px: { xs: 2, sm: 3 } }) }), (0, jsx_runtime_1.jsx)(OutputView, { resultTitle: resultTitle, className: "aigne-outputs aigne-photo-wall-outputs", gap: 2 })] }));
54
36
  }
55
37
  exports.default = PhotoGallery;
56
38
  function AgentInputRender(_a) {
@@ -30,27 +30,9 @@ const BackgroundImage_1 = __importDefault(require("./BackgroundImage"));
30
30
  const InputsView_1 = __importDefault(require("./InputsView"));
31
31
  const MessagesView_1 = __importDefault(require("./MessagesView"));
32
32
  function SimpleChat(_a) {
33
- var { primaryColor, scrollViewProps = { scroll: 'window', initialScrollBehavior: 'auto' } } = _a, preferences = __rest(_a, ["primaryColor", "scrollViewProps"]);
33
+ var { scrollViewProps = { scroll: 'window', initialScrollBehavior: 'auto' } } = _a, preferences = __rest(_a, ["scrollViewProps"]);
34
34
  (0, session_1.useAutoLoadSessionState)();
35
- const inheritedTheme = (0, material_1.useTheme)();
36
- const theme = (0, react_1.useMemo)(() => {
37
- let { primary } = inheritedTheme.palette;
38
- try {
39
- if (primaryColor) {
40
- primary = inheritedTheme.palette.augmentColor({ color: { main: primaryColor } });
41
- }
42
- }
43
- catch (error) {
44
- console.error('augment primary color error', { error });
45
- }
46
- return (0, material_1.createTheme)(inheritedTheme, {
47
- palette: { primary },
48
- shape: {
49
- borderRadius: 8,
50
- },
51
- });
52
- }, [inheritedTheme, primaryColor]);
53
- return ((0, jsx_runtime_1.jsx)(ComponentPreferences_1.ComponentPreferencesProvider, Object.assign({}, preferences, { children: (0, jsx_runtime_1.jsx)(ScrollView_1.default, Object.assign({}, scrollViewProps, { children: (0, jsx_runtime_1.jsxs)(material_1.ThemeProvider, { theme: theme, children: [(0, jsx_runtime_1.jsx)(BackgroundImage_1.default, {}), (0, jsx_runtime_1.jsx)(SimpleChatView, {})] }) })) })));
35
+ return ((0, jsx_runtime_1.jsx)(ComponentPreferences_1.ComponentPreferencesProvider, Object.assign({}, preferences, { children: (0, jsx_runtime_1.jsxs)(ScrollView_1.default, Object.assign({}, scrollViewProps, { children: [(0, jsx_runtime_1.jsx)(BackgroundImage_1.default, {}), (0, jsx_runtime_1.jsx)(SimpleChatView, {})] })) })));
54
36
  }
55
37
  exports.default = SimpleChat;
56
38
  function SimpleChatView() {
@@ -26,28 +26,10 @@ const CurrentAgent_1 = __importDefault(require("../../contexts/CurrentAgent"));
26
26
  const CurrentMessage_1 = __importDefault(require("../../contexts/CurrentMessage"));
27
27
  const use_appearances_1 = __importDefault(require("../../hooks/use-appearances"));
28
28
  const session_1 = require("../../state/session");
29
- function SimplePage({ resultTitle, primaryColor }) {
29
+ function SimplePage({ resultTitle }) {
30
30
  const { activeAgentId } = (0, ActiveAgent_1.useActiveAgent)();
31
31
  (0, session_1.useAutoLoadSessionState)();
32
- const inheritedTheme = (0, material_1.useTheme)();
33
- const theme = (0, react_1.useMemo)(() => {
34
- let { primary } = inheritedTheme.palette;
35
- try {
36
- if (primaryColor) {
37
- primary = inheritedTheme.palette.augmentColor({ color: { main: primaryColor } });
38
- }
39
- }
40
- catch (error) {
41
- console.error('augment primary color error', { error });
42
- }
43
- return (0, material_1.createTheme)(inheritedTheme, {
44
- palette: { primary },
45
- shape: {
46
- borderRadius: 8,
47
- },
48
- });
49
- }, [inheritedTheme, primaryColor]);
50
- return ((0, jsx_runtime_1.jsx)(material_1.ThemeProvider, { theme: theme, children: (0, jsx_runtime_1.jsxs)(SimpleLayout_1.default, { pb: 4, children: [(0, jsx_runtime_1.jsx)(SimpleHeader_1.default, {}), (0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: activeAgentId, children: (0, jsx_runtime_1.jsx)(AgentInputRender, { className: "aigne-inputs aigne-simple-page-inputs" }) }), (0, jsx_runtime_1.jsx)(OutputView, { className: "aigne-outputs aigne-simple-page-outputs", resultTitle: resultTitle })] }) }));
32
+ return ((0, jsx_runtime_1.jsxs)(SimpleLayout_1.default, { pb: 4, children: [(0, jsx_runtime_1.jsx)(SimpleHeader_1.default, {}), (0, jsx_runtime_1.jsx)(CurrentAgent_1.default, { agentId: activeAgentId, children: (0, jsx_runtime_1.jsx)(AgentInputRender, { className: "aigne-inputs aigne-simple-page-inputs" }) }), (0, jsx_runtime_1.jsx)(OutputView, { className: "aigne-outputs aigne-simple-page-outputs", resultTitle: resultTitle })] }));
51
33
  }
52
34
  exports.default = SimplePage;
53
35
  function AgentInputRender(_a) {