@blocklet/pages-kit 0.2.323 → 0.2.325
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 +32 -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 +32 -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
|
@@ -30,9 +30,9 @@ export default function V0Input({ submitText, inlineLabel, autoFillLastForm = fa
|
|
|
30
30
|
const { aid, agent } = useCurrentAgent();
|
|
31
31
|
const [executeLoading, setExecuteLoading] = useState(false);
|
|
32
32
|
const opening = useOpeningQuestions();
|
|
33
|
-
const { execute
|
|
33
|
+
const { execute } = useRuntimeState();
|
|
34
34
|
const { running } = useCurrentSessionState((s) => s) || {};
|
|
35
|
-
const {
|
|
35
|
+
const { currentSessionId } = useSessionState((s) => s) || {};
|
|
36
36
|
const { setCurrentMessageTaskId } = useV0RuntimeContext();
|
|
37
37
|
const parameters = useMemo(() => {
|
|
38
38
|
var _a;
|
|
@@ -51,15 +51,9 @@ export default function V0Input({ submitText, inlineLabel, autoFillLastForm = fa
|
|
|
51
51
|
}, [defaultForm, autoFillLastForm, form, chatMode]);
|
|
52
52
|
const onSubmit = (parameters) => __awaiter(this, void 0, void 0, function* () {
|
|
53
53
|
try {
|
|
54
|
-
yield checkLoginState();
|
|
55
54
|
if (!(parameters === null || parameters === void 0 ? void 0 : parameters.question))
|
|
56
55
|
return;
|
|
57
56
|
setExecuteLoading(true);
|
|
58
|
-
if (!currentSessionId) {
|
|
59
|
-
yield createSession({
|
|
60
|
-
name: parameters === null || parameters === void 0 ? void 0 : parameters.question,
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
57
|
// in session page, send message
|
|
64
58
|
yield execute({
|
|
65
59
|
aid,
|
|
@@ -35,7 +35,10 @@ export default function V0Output() {
|
|
|
35
35
|
const { propertiesValueMap, setPropertiesValueMap, isMobile } = useV0RuntimeContext();
|
|
36
36
|
const [code, setCode] = useState('');
|
|
37
37
|
const { t, locale } = useLocaleContext();
|
|
38
|
-
const [
|
|
38
|
+
const [codePreviewExtraProps, setCodePreviewExtraProps] = useState({
|
|
39
|
+
sx: DEFAULT_DESKTOP_SX,
|
|
40
|
+
key: 'Desktop',
|
|
41
|
+
});
|
|
39
42
|
const objects = (_a = message.result) === null || _a === void 0 ? void 0 : _a.objects;
|
|
40
43
|
const { taskId, parameters } = message;
|
|
41
44
|
const isMessageLoading = (message.loading || !message.result) && !message.error;
|
|
@@ -43,14 +46,24 @@ export default function V0Output() {
|
|
|
43
46
|
const responsiveSx = {
|
|
44
47
|
backgroundColor: 'white',
|
|
45
48
|
borderColor: 'rgba(0, 0, 0, 0.1) !important',
|
|
49
|
+
// rewrite disabled style
|
|
50
|
+
'&.frame-button.Mui-disabled': {
|
|
51
|
+
backgroundColor: 'primary.main',
|
|
52
|
+
color: 'white',
|
|
53
|
+
},
|
|
46
54
|
};
|
|
47
55
|
const tooltipOptions = [
|
|
48
56
|
!isMobile && {
|
|
49
57
|
key: 'Desktop',
|
|
50
58
|
icon: 'tabler:device-desktop',
|
|
51
59
|
props: {
|
|
60
|
+
className: 'frame-button',
|
|
61
|
+
disabled: (codePreviewExtraProps === null || codePreviewExtraProps === void 0 ? void 0 : codePreviewExtraProps.key) === 'Desktop',
|
|
52
62
|
sx: Object.assign({}, responsiveSx),
|
|
53
|
-
onClick: () =>
|
|
63
|
+
onClick: () => setCodePreviewExtraProps({
|
|
64
|
+
sx: DEFAULT_DESKTOP_SX,
|
|
65
|
+
key: 'Desktop',
|
|
66
|
+
}),
|
|
54
67
|
},
|
|
55
68
|
group: 'responsive',
|
|
56
69
|
},
|
|
@@ -58,10 +71,15 @@ export default function V0Output() {
|
|
|
58
71
|
key: 'Tablet',
|
|
59
72
|
icon: 'tabler:device-tablet',
|
|
60
73
|
props: {
|
|
74
|
+
className: 'frame-button',
|
|
75
|
+
disabled: (codePreviewExtraProps === null || codePreviewExtraProps === void 0 ? void 0 : codePreviewExtraProps.key) === 'Tablet',
|
|
61
76
|
sx: Object.assign({}, responsiveSx),
|
|
62
|
-
onClick: () =>
|
|
63
|
-
|
|
64
|
-
|
|
77
|
+
onClick: () => setCodePreviewExtraProps({
|
|
78
|
+
sx: {
|
|
79
|
+
width: '768px',
|
|
80
|
+
height: '1024px',
|
|
81
|
+
},
|
|
82
|
+
key: 'Tablet',
|
|
65
83
|
}),
|
|
66
84
|
},
|
|
67
85
|
group: 'responsive',
|
|
@@ -70,10 +88,15 @@ export default function V0Output() {
|
|
|
70
88
|
key: 'Mobile',
|
|
71
89
|
icon: 'tabler:device-mobile',
|
|
72
90
|
props: {
|
|
91
|
+
className: 'frame-button',
|
|
92
|
+
disabled: (codePreviewExtraProps === null || codePreviewExtraProps === void 0 ? void 0 : codePreviewExtraProps.key) === 'Mobile',
|
|
73
93
|
sx: Object.assign({}, responsiveSx),
|
|
74
|
-
onClick: () =>
|
|
75
|
-
|
|
76
|
-
|
|
94
|
+
onClick: () => setCodePreviewExtraProps({
|
|
95
|
+
sx: {
|
|
96
|
+
width: '375px',
|
|
97
|
+
height: '667px',
|
|
98
|
+
},
|
|
99
|
+
key: 'Mobile',
|
|
77
100
|
}),
|
|
78
101
|
},
|
|
79
102
|
group: 'responsive',
|
|
@@ -197,7 +220,7 @@ export default function V0Output() {
|
|
|
197
220
|
const { icon, key, props, buttonText } = option;
|
|
198
221
|
return (_jsxs(Button, Object.assign({ "data-taskId": taskId }, props, { children: [_jsx(Icon, { icon: icon, fontSize: 22 }), buttonText && _jsx(Box, { sx: { ml: 1 }, children: buttonText })] }), key));
|
|
199
222
|
}) }, group));
|
|
200
|
-
}) })] }), _jsx(Box, { sx: Object.assign({ display: 'flex', justifyContent: 'center', overflow: 'hidden', backgroundColor: 'white', borderRadius: 1 },
|
|
223
|
+
}) })] }), _jsx(Box, { sx: Object.assign({ display: 'flex', justifyContent: 'center', overflow: 'hidden', backgroundColor: 'white', borderRadius: 1 }, codePreviewExtraProps === null || codePreviewExtraProps === void 0 ? void 0 : codePreviewExtraProps.sx), children: _jsx(CodeRenderByMessage, { message: message, zoom: 1, sx: {
|
|
201
224
|
overflowX: 'auto',
|
|
202
225
|
overflowY: 'auto',
|
|
203
226
|
scrollbarWidth: 'thin',
|
|
@@ -8,6 +8,7 @@ import { getLineClamp } from '../utils';
|
|
|
8
8
|
const BASE_QUESTION_SX = {
|
|
9
9
|
fontWeight: 500,
|
|
10
10
|
fontSize: 13,
|
|
11
|
+
lineHeight: 1.6,
|
|
11
12
|
};
|
|
12
13
|
export default function UserQuestion({ question }) {
|
|
13
14
|
var _a;
|
|
@@ -27,5 +28,9 @@ export default function UserQuestion({ question }) {
|
|
|
27
28
|
// borderTopLeftRadius: 0,
|
|
28
29
|
backgroundColor: 'grey.200',
|
|
29
30
|
maxWidth: 300,
|
|
30
|
-
}, children: _jsx(CopyButton, { locale: locale, unstyled: true, render: ({
|
|
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 }) }) }) }));
|
|
35
|
+
} }) })] }));
|
|
31
36
|
}
|
|
@@ -13,7 +13,7 @@ import { useRuntimeContext } from '../contexts/Runtime';
|
|
|
13
13
|
import { useAgentState } from './agent';
|
|
14
14
|
import { createSessionState } from './session';
|
|
15
15
|
export function useRuntimeState() {
|
|
16
|
-
var _a
|
|
16
|
+
var _a;
|
|
17
17
|
const { aid, working } = useRuntimeContext();
|
|
18
18
|
const [agent] = useAgentState({ aid, working });
|
|
19
19
|
const { session: authSession } = useSessionContext();
|
|
@@ -38,11 +38,5 @@ export function useRuntimeState() {
|
|
|
38
38
|
}
|
|
39
39
|
return exec(Object.assign(Object.assign({}, args), { working }));
|
|
40
40
|
}), [authSession.user, exec, working, login]);
|
|
41
|
-
|
|
42
|
-
var _c;
|
|
43
|
-
if (!((_c = authSession.user) === null || _c === void 0 ? void 0 : _c.did)) {
|
|
44
|
-
yield login();
|
|
45
|
-
}
|
|
46
|
-
}), [!((_b = authSession.user) === null || _b === void 0 ? void 0 : _b.did)]);
|
|
47
|
-
return { aid, working, agent, execute, checkLoginState };
|
|
41
|
+
return { aid, working, agent, execute };
|
|
48
42
|
}
|
|
@@ -244,7 +244,11 @@ export const createSessionState = ({ aid }) => {
|
|
|
244
244
|
execute: (_g) => __awaiter(void 0, void 0, void 0, function* () {
|
|
245
245
|
var _h, e_1, _j, _k;
|
|
246
246
|
var { aid, working, parameters, onResponseStart } = _g, args = __rest(_g, ["aid", "working", "parameters", "onResponseStart"]);
|
|
247
|
-
const sessionId = args.sessionId ||
|
|
247
|
+
const sessionId = args.sessionId ||
|
|
248
|
+
get().currentSessionId ||
|
|
249
|
+
(yield get().createSession({
|
|
250
|
+
name: parameters === null || parameters === void 0 ? void 0 : parameters.question,
|
|
251
|
+
})).id;
|
|
248
252
|
const identity = parseIdentity(aid, { rejectWhenError: true });
|
|
249
253
|
let message;
|
|
250
254
|
set((state) => {
|