@blocklet/pages-kit 0.2.323 → 0.2.324
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/runtime-components/V0/Input.js +2 -8
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/Output.js +29 -9
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/components/UserQuestion.js +6 -1
- package/lib/cjs/builtin/async/ai-runtime/state/runtime.js +2 -8
- package/lib/cjs/builtin/async/ai-runtime/state/session.js +5 -1
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/Input.js +2 -8
- package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/Output.js +29 -9
- package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/components/UserQuestion.js +6 -1
- package/lib/esm/builtin/async/ai-runtime/state/runtime.js +2 -8
- package/lib/esm/builtin/async/ai-runtime/state/session.js +5 -1
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/lib/types/builtin/async/ai-runtime/state/runtime.d.ts +0 -1
- package/lib/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -35,9 +35,9 @@ function V0Input({ submitText, inlineLabel, autoFillLastForm = false, submitInQu
|
|
|
35
35
|
const { aid, agent } = (0, CurrentAgent_1.useCurrentAgent)();
|
|
36
36
|
const [executeLoading, setExecuteLoading] = (0, react_2.useState)(false);
|
|
37
37
|
const opening = (0, use_appearances_1.useOpeningQuestions)();
|
|
38
|
-
const { execute
|
|
38
|
+
const { execute } = (0, runtime_1.useRuntimeState)();
|
|
39
39
|
const { running } = (0, session_1.useCurrentSessionState)((s) => s) || {};
|
|
40
|
-
const {
|
|
40
|
+
const { currentSessionId } = (0, session_1.useSessionState)((s) => s) || {};
|
|
41
41
|
const { setCurrentMessageTaskId } = (0, V0Runtime_1.useV0RuntimeContext)();
|
|
42
42
|
const parameters = (0, react_2.useMemo)(() => {
|
|
43
43
|
var _a;
|
|
@@ -56,15 +56,9 @@ function V0Input({ submitText, inlineLabel, autoFillLastForm = false, submitInQu
|
|
|
56
56
|
}, [defaultForm, autoFillLastForm, form, chatMode]);
|
|
57
57
|
const onSubmit = (parameters) => __awaiter(this, void 0, void 0, function* () {
|
|
58
58
|
try {
|
|
59
|
-
yield checkLoginState();
|
|
60
59
|
if (!(parameters === null || parameters === void 0 ? void 0 : parameters.question))
|
|
61
60
|
return;
|
|
62
61
|
setExecuteLoading(true);
|
|
63
|
-
if (!currentSessionId) {
|
|
64
|
-
yield createSession({
|
|
65
|
-
name: parameters === null || parameters === void 0 ? void 0 : parameters.question,
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
62
|
// in session page, send message
|
|
69
63
|
yield execute({
|
|
70
64
|
aid,
|
|
@@ -40,7 +40,10 @@ function V0Output() {
|
|
|
40
40
|
const { propertiesValueMap, setPropertiesValueMap, isMobile } = (0, V0Runtime_1.useV0RuntimeContext)();
|
|
41
41
|
const [code, setCode] = (0, react_2.useState)('');
|
|
42
42
|
const { t, locale } = (0, locale_1.useLocaleContext)();
|
|
43
|
-
const [
|
|
43
|
+
const [codePreviewExtraProps, setCodePreviewExtraProps] = (0, react_2.useState)({
|
|
44
|
+
sx: DEFAULT_DESKTOP_SX,
|
|
45
|
+
key: 'Desktop',
|
|
46
|
+
});
|
|
44
47
|
const objects = (_a = message.result) === null || _a === void 0 ? void 0 : _a.objects;
|
|
45
48
|
const { taskId, parameters } = message;
|
|
46
49
|
const isMessageLoading = (message.loading || !message.result) && !message.error;
|
|
@@ -48,14 +51,23 @@ function V0Output() {
|
|
|
48
51
|
const responsiveSx = {
|
|
49
52
|
backgroundColor: 'white',
|
|
50
53
|
borderColor: 'rgba(0, 0, 0, 0.1) !important',
|
|
54
|
+
// rewrite disabled style
|
|
55
|
+
'&.Mui-disabled': {
|
|
56
|
+
backgroundColor: 'primary.main',
|
|
57
|
+
color: 'white',
|
|
58
|
+
},
|
|
51
59
|
};
|
|
52
60
|
const tooltipOptions = [
|
|
53
61
|
!isMobile && {
|
|
54
62
|
key: 'Desktop',
|
|
55
63
|
icon: 'tabler:device-desktop',
|
|
56
64
|
props: {
|
|
65
|
+
disabled: (codePreviewExtraProps === null || codePreviewExtraProps === void 0 ? void 0 : codePreviewExtraProps.key) === 'Desktop',
|
|
57
66
|
sx: Object.assign({}, responsiveSx),
|
|
58
|
-
onClick: () =>
|
|
67
|
+
onClick: () => setCodePreviewExtraProps({
|
|
68
|
+
sx: DEFAULT_DESKTOP_SX,
|
|
69
|
+
key: 'Desktop',
|
|
70
|
+
}),
|
|
59
71
|
},
|
|
60
72
|
group: 'responsive',
|
|
61
73
|
},
|
|
@@ -63,10 +75,14 @@ function V0Output() {
|
|
|
63
75
|
key: 'Tablet',
|
|
64
76
|
icon: 'tabler:device-tablet',
|
|
65
77
|
props: {
|
|
78
|
+
disabled: (codePreviewExtraProps === null || codePreviewExtraProps === void 0 ? void 0 : codePreviewExtraProps.key) === 'Tablet',
|
|
66
79
|
sx: Object.assign({}, responsiveSx),
|
|
67
|
-
onClick: () =>
|
|
68
|
-
|
|
69
|
-
|
|
80
|
+
onClick: () => setCodePreviewExtraProps({
|
|
81
|
+
sx: {
|
|
82
|
+
width: '768px',
|
|
83
|
+
height: '1024px',
|
|
84
|
+
},
|
|
85
|
+
key: 'Tablet',
|
|
70
86
|
}),
|
|
71
87
|
},
|
|
72
88
|
group: 'responsive',
|
|
@@ -75,10 +91,14 @@ function V0Output() {
|
|
|
75
91
|
key: 'Mobile',
|
|
76
92
|
icon: 'tabler:device-mobile',
|
|
77
93
|
props: {
|
|
94
|
+
disabled: (codePreviewExtraProps === null || codePreviewExtraProps === void 0 ? void 0 : codePreviewExtraProps.key) === 'Mobile',
|
|
78
95
|
sx: Object.assign({}, responsiveSx),
|
|
79
|
-
onClick: () =>
|
|
80
|
-
|
|
81
|
-
|
|
96
|
+
onClick: () => setCodePreviewExtraProps({
|
|
97
|
+
sx: {
|
|
98
|
+
width: '375px',
|
|
99
|
+
height: '667px',
|
|
100
|
+
},
|
|
101
|
+
key: 'Mobile',
|
|
82
102
|
}),
|
|
83
103
|
},
|
|
84
104
|
group: 'responsive',
|
|
@@ -202,7 +222,7 @@ function V0Output() {
|
|
|
202
222
|
const { icon, key, props, buttonText } = option;
|
|
203
223
|
return ((0, jsx_runtime_1.jsxs)(material_1.Button, Object.assign({ "data-taskId": taskId }, props, { children: [(0, jsx_runtime_1.jsx)(react_1.Icon, { icon: icon, fontSize: 22 }), buttonText && (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { ml: 1 }, children: buttonText })] }), key));
|
|
204
224
|
}) }, group));
|
|
205
|
-
}) })] }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: Object.assign({ display: 'flex', justifyContent: 'center', overflow: 'hidden', backgroundColor: 'white', borderRadius: 1 },
|
|
225
|
+
}) })] }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: Object.assign({ display: 'flex', justifyContent: 'center', overflow: 'hidden', backgroundColor: 'white', borderRadius: 1 }, codePreviewExtraProps === null || codePreviewExtraProps === void 0 ? void 0 : codePreviewExtraProps.sx), children: (0, jsx_runtime_1.jsx)(CodePreview_1.CodeRenderByMessageMemo, { message: message, zoom: 1, sx: {
|
|
206
226
|
overflowX: 'auto',
|
|
207
227
|
overflowY: 'auto',
|
|
208
228
|
scrollbarWidth: 'thin',
|
|
@@ -33,6 +33,7 @@ const utils_1 = require("../utils");
|
|
|
33
33
|
const BASE_QUESTION_SX = {
|
|
34
34
|
fontWeight: 500,
|
|
35
35
|
fontSize: 13,
|
|
36
|
+
lineHeight: 1.6,
|
|
36
37
|
};
|
|
37
38
|
function UserQuestion({ question }) {
|
|
38
39
|
var _a;
|
|
@@ -52,6 +53,10 @@ function UserQuestion({ question }) {
|
|
|
52
53
|
// borderTopLeftRadius: 0,
|
|
53
54
|
backgroundColor: 'grey.200',
|
|
54
55
|
maxWidth: 300,
|
|
55
|
-
}, children: (0, jsx_runtime_1.jsx)(ClickToCopy_1.CopyButton, { locale: locale, unstyled: true, render: ({
|
|
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.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsxs)(material_1.Typography, { sx: Object.assign(Object.assign({}, BASE_QUESTION_SX), { color: 'white' }), children: [question, (0, jsx_runtime_1.jsx)(material_1.Box, { id: "copy-button-wrapper", component: "span", sx: {
|
|
58
|
+
ml: 0.5,
|
|
59
|
+
}, 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
|
+
} }) })] }));
|
|
56
61
|
}
|
|
57
62
|
exports.default = UserQuestion;
|
|
@@ -16,7 +16,7 @@ const Runtime_1 = require("../contexts/Runtime");
|
|
|
16
16
|
const agent_1 = require("./agent");
|
|
17
17
|
const session_2 = require("./session");
|
|
18
18
|
function useRuntimeState() {
|
|
19
|
-
var _a
|
|
19
|
+
var _a;
|
|
20
20
|
const { aid, working } = (0, Runtime_1.useRuntimeContext)();
|
|
21
21
|
const [agent] = (0, agent_1.useAgentState)({ aid, working });
|
|
22
22
|
const { session: authSession } = (0, session_1.useSessionContext)();
|
|
@@ -41,12 +41,6 @@ function useRuntimeState() {
|
|
|
41
41
|
}
|
|
42
42
|
return exec(Object.assign(Object.assign({}, args), { working }));
|
|
43
43
|
}), [authSession.user, exec, working, login]);
|
|
44
|
-
|
|
45
|
-
var _c;
|
|
46
|
-
if (!((_c = authSession.user) === null || _c === void 0 ? void 0 : _c.did)) {
|
|
47
|
-
yield login();
|
|
48
|
-
}
|
|
49
|
-
}), [!((_b = authSession.user) === null || _b === void 0 ? void 0 : _b.did)]);
|
|
50
|
-
return { aid, working, agent, execute, checkLoginState };
|
|
44
|
+
return { aid, working, agent, execute };
|
|
51
45
|
}
|
|
52
46
|
exports.useRuntimeState = useRuntimeState;
|
|
@@ -247,7 +247,11 @@ const createSessionState = ({ aid }) => {
|
|
|
247
247
|
execute: (_g) => __awaiter(void 0, void 0, void 0, function* () {
|
|
248
248
|
var _h, e_1, _j, _k;
|
|
249
249
|
var { aid, working, parameters, onResponseStart } = _g, args = __rest(_g, ["aid", "working", "parameters", "onResponseStart"]);
|
|
250
|
-
const sessionId = args.sessionId ||
|
|
250
|
+
const sessionId = args.sessionId ||
|
|
251
|
+
get().currentSessionId ||
|
|
252
|
+
(yield get().createSession({
|
|
253
|
+
name: parameters === null || parameters === void 0 ? void 0 : parameters.question,
|
|
254
|
+
})).id;
|
|
251
255
|
const identity = (0, aid_1.parseIdentity)(aid, { rejectWhenError: true });
|
|
252
256
|
let message;
|
|
253
257
|
set((state) => {
|