@blocklet/pages-kit 0.2.353 → 0.2.355
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/api/call.js +1 -2
- package/lib/cjs/api/pages-kit.js +1 -2
- package/lib/cjs/builtin/async/ai-runtime/api/agent.js +1 -2
- package/lib/cjs/builtin/async/ai-runtime/api/dataset.js +11 -12
- package/lib/cjs/builtin/async/ai-runtime/api/message.js +2 -3
- package/lib/cjs/builtin/async/ai-runtime/api/request.js +2 -2
- package/lib/cjs/builtin/async/ai-runtime/api/secret.js +1 -2
- package/lib/cjs/builtin/async/ai-runtime/api/session.js +7 -8
- package/lib/cjs/builtin/async/ai-runtime/components/ActionButton.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/components/AgentErrorBoundary.js +6 -4
- package/lib/cjs/builtin/async/ai-runtime/components/AgentInputField/index.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/components/AgentSettings/AgentSettingsDialog.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/components/GlobalLoading/index.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/components/Header/SimpleHeader.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/components/Layout/SimpleLayout.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/components/MenuButton.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/components/OutputFieldContainer/index.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/components/PopperMenuButton/LoadingMenuItem.js +3 -3
- package/lib/cjs/builtin/async/ai-runtime/components/PopperMenuButton/index.js +3 -3
- package/lib/cjs/builtin/async/ai-runtime/components/RuntimeCommonProvider.js +2 -3
- package/lib/cjs/builtin/async/ai-runtime/components/ScrollView.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/components/ShareActions/index.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/components/SocialShare.js +3 -4
- package/lib/cjs/builtin/async/ai-runtime/components/ThemeProvider.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/components/UserInfo.js +3 -4
- package/lib/cjs/builtin/async/ai-runtime/constants.js +2 -2
- package/lib/cjs/builtin/async/ai-runtime/contexts/ActiveAgent.js +2 -3
- package/lib/cjs/builtin/async/ai-runtime/contexts/ComponentPreferences.js +2 -3
- package/lib/cjs/builtin/async/ai-runtime/contexts/CurrentAgent.js +2 -3
- package/lib/cjs/builtin/async/ai-runtime/contexts/CurrentMessage.js +2 -3
- package/lib/cjs/builtin/async/ai-runtime/contexts/Runtime.js +3 -4
- package/lib/cjs/builtin/async/ai-runtime/hooks/use-agent-admin.js +1 -2
- package/lib/cjs/builtin/async/ai-runtime/hooks/use-appearances.js +4 -5
- package/lib/cjs/builtin/async/ai-runtime/hooks/use-header-menu.js +1 -2
- package/lib/cjs/builtin/async/ai-runtime/runtime/ChatBotButton/index.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/runtime/Runtime/index.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/AutoForm/index.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/ChatOutput/MessageErrorView.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/ChatOutput/MessageItemView.js +1 -2
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/ChatOutput/MessageMetadataRenderer.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/ChatOutput/MessageSuggestedQuestions.js +2 -3
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/ChatOutput/ReferenceLinks.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/ChatOutput/index.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/GoogleSearch/GoogleSearchRelatedQuestionsView.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/GoogleSearch/GoogleSearchSourcesView.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/ImagesView/index.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/MarkdownView/index.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/OpeningQuestionsView/index.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/PhotoGallery/index.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/PhotoGalleryItem/index.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/ReferencedLinksView/index.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/ShareView/index.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/BackgroundImage.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/InputsView.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/MessageView.js +1 -2
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/MessagesView.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/UserMessageView.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleChat/index.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimpleOutput/index.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SimplePage/index.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/SuggestedQuestionsView/index.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/Input.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/Output.js +3 -3
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/Page.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/components/CodePreview.js +4 -4
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/components/Loading.js +2 -3
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/components/UserQuestion.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/runtime-components/V0/contexts/V0Runtime.js +2 -3
- package/lib/cjs/builtin/async/ai-runtime/state/agent.js +1 -2
- package/lib/cjs/builtin/async/ai-runtime/state/runtime.js +1 -2
- package/lib/cjs/builtin/async/ai-runtime/state/session.js +21 -21
- package/lib/cjs/builtin/async/ai-runtime/utils/agent-inputs.js +2 -2
- package/lib/cjs/builtin/async/ai-runtime/utils/download-image.js +2 -3
- package/lib/cjs/builtin/async/ai-runtime/utils/map-right.js +1 -1
- package/lib/cjs/builtin/async/ai-runtime/utils/runtime-output-schema.js +1 -2
- package/lib/cjs/builtin/async/ai-runtime/utils/zustand.js +1 -2
- package/lib/cjs/builtin/call.js +1 -2
- package/lib/cjs/builtin/iconify/react.js +1 -2
- package/lib/cjs/builtin/page/header.js +2 -2
- package/lib/cjs/builtin/session.js +1 -2
- package/lib/cjs/builtin/utils.js +2 -2
- package/lib/cjs/components/CustomComponentRenderer/BlockletReactComponentRenderer.js +1 -1
- package/lib/cjs/components/CustomComponentRenderer/DevProvider.js +2 -3
- package/lib/cjs/components/CustomComponentRenderer/index.js +1 -1
- package/lib/cjs/components/CustomComponentRenderer/state.js +3 -3
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/utils/preload.js +1 -2
- package/lib/cjs/utils/property.js +5 -5
- package/lib/esm/builtin/async/ai-runtime/components/AgentErrorBoundary.js +4 -1
- package/lib/esm/builtin/async/ai-runtime/components/PopperMenuButton/LoadingMenuItem.js +2 -2
- package/lib/esm/builtin/async/ai-runtime/components/PopperMenuButton/index.js +2 -2
- package/lib/esm/builtin/async/ai-runtime/runtime-components/V0/Output.js +2 -2
- package/lib/esm/builtin/async/ai-runtime/state/session.js +17 -17
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/lib/types/builtin/async/ai-runtime/api/request.d.ts +1 -1
- package/lib/types/builtin/async/ai-runtime/components/AgentInputField/LanguageField.d.ts +2 -3
- package/lib/types/builtin/async/ai-runtime/components/AgentInputField/NumberField.d.ts +2 -3
- package/lib/types/builtin/async/ai-runtime/components/AgentInputField/RadioField.d.ts +2 -3
- package/lib/types/builtin/async/ai-runtime/components/AgentInputField/SelectField.d.ts +2 -3
- package/lib/types/builtin/async/ai-runtime/components/AgentInputField/StringField.d.ts +2 -3
- package/lib/types/builtin/async/ai-runtime/components/LoadingButton.d.ts +0 -1
- package/lib/types/builtin/async/ai-runtime/hooks/use-appearances.d.ts +7 -7
- package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/MessageView.d.ts +0 -1
- package/lib/types/builtin/async/ai-runtime/runtime-components/SimpleChat/OpeningMessageView.d.ts +0 -1
- package/lib/types/builtin/async/ai-runtime/runtime-components/V0/components/CodePreview.d.ts +0 -1
- package/lib/types/builtin/async/ai-runtime/runtime-components/V0/components/ConfirmDialog.d.ts +0 -1
- package/lib/types/builtin/async/ai-runtime/runtime-components/V0/components/PropertiesSetting.d.ts +0 -1
- package/lib/types/builtin/async/ai-runtime/state/runtime.d.ts +4 -4
- package/lib/types/builtin/async/react-scroll-to-bottom.d.ts +22 -23
- package/lib/types/builtin/async/react-syntax-highlighter.d.ts +0 -1
- package/lib/types/builtin/call.d.ts +0 -1
- package/lib/types/tsconfig.tsbuildinfo +1 -1
- package/lib/types/utils/typescript/builtin-module-transformer.d.ts +1 -1
- package/lib/types/utils/typescript/imports-removal-transformer.d.ts +1 -1
- package/package.json +6 -6
|
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.default = V0Output;
|
|
15
16
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
17
|
const Toast_1 = __importDefault(require("@arcblock/ux/lib/Toast"));
|
|
17
18
|
const react_1 = require("@iconify/react");
|
|
@@ -114,8 +115,8 @@ function V0Output() {
|
|
|
114
115
|
disabled,
|
|
115
116
|
sx: Object.assign({}, responsiveSx),
|
|
116
117
|
onClick: (e) => __awaiter(this, void 0, void 0, function* () {
|
|
117
|
-
var
|
|
118
|
-
const { taskid: taskId } = ((
|
|
118
|
+
var _a;
|
|
119
|
+
const { taskid: taskId } = ((_a = e === null || e === void 0 ? void 0 : e.currentTarget) === null || _a === void 0 ? void 0 : _a.dataset) || {};
|
|
119
120
|
const currentCode = (0, CodePreview_1.getCurrentCodeByTaskId)(message);
|
|
120
121
|
try {
|
|
121
122
|
yield (0, CustomComponentRenderer_1.transpileAndLoadScript)(currentCode).then((m) => {
|
|
@@ -249,4 +250,3 @@ function V0Output() {
|
|
|
249
250
|
fontSize: 22,
|
|
250
251
|
}, children: (0, jsx_runtime_1.jsx)(react_1.Icon, { icon: "tabler:x" }) })] }), (0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "info", sx: { mb: 2 }, children: t('v0.codePreviewTip') }), (0, jsx_runtime_1.jsx)(MarkdownRenderer_1.default, { children: `\`\`\`typescript\n${code}\n\`\`\`` })] }) }), (0, jsx_runtime_1.jsx)(PropertiesSetting_1.default, { ref: propertiesSettingRef })] })] }));
|
|
251
252
|
}
|
|
252
|
-
exports.default = V0Output;
|
|
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.default = Page;
|
|
15
16
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
17
|
const Empty_1 = __importDefault(require("@arcblock/ux/lib/Empty"));
|
|
17
18
|
const RelativeTime_1 = __importDefault(require("@arcblock/ux/lib/RelativeTime"));
|
|
@@ -84,7 +85,6 @@ function V0Page({ textColor = '#333', primaryColor = '#333' }) {
|
|
|
84
85
|
function Page() {
|
|
85
86
|
return ((0, jsx_runtime_1.jsx)(V0Runtime_1.V0RuntimeProvider, { children: (0, jsx_runtime_1.jsx)(V0Page, {}) }));
|
|
86
87
|
}
|
|
87
|
-
exports.default = Page;
|
|
88
88
|
function V0ListRender() {
|
|
89
89
|
var _a, _b;
|
|
90
90
|
const ConfirmDialogRef = (0, react_2.useRef)();
|
|
@@ -23,7 +23,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
23
23
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
26
|
+
exports.CodeRenderByMessageMemo = exports.CodePreviewMemo = void 0;
|
|
27
|
+
exports.default = CodePreview;
|
|
28
|
+
exports.CodeRenderByMessage = CodeRenderByMessage;
|
|
29
|
+
exports.getCurrentCodeByTaskId = getCurrentCodeByTaskId;
|
|
27
30
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
28
31
|
const react_1 = require("@iconify/react");
|
|
29
32
|
const material_1 = require("@mui/material");
|
|
@@ -108,7 +111,6 @@ function CodePreview(_a) {
|
|
|
108
111
|
},
|
|
109
112
|
} }) }), componentId));
|
|
110
113
|
}
|
|
111
|
-
exports.default = CodePreview;
|
|
112
114
|
exports.CodePreviewMemo = (0, react_2.memo)(CodePreview);
|
|
113
115
|
function CodeRenderByMessage({ zoom, message, minHeight = 200, sx, propertiesValueMap, }) {
|
|
114
116
|
var _a;
|
|
@@ -146,10 +148,8 @@ function CodeRenderByMessage({ zoom, message, minHeight = 200, sx, propertiesVal
|
|
|
146
148
|
// p: 2,
|
|
147
149
|
} }), children: (0, jsx_runtime_1.jsx)(ContentRender, {}) }, message === null || message === void 0 ? void 0 : message.id));
|
|
148
150
|
}
|
|
149
|
-
exports.CodeRenderByMessage = CodeRenderByMessage;
|
|
150
151
|
exports.CodeRenderByMessageMemo = (0, react_2.memo)(CodeRenderByMessage);
|
|
151
152
|
function getCurrentCodeByTaskId(message) {
|
|
152
153
|
var _a, _b, _c;
|
|
153
154
|
return (_c = (_b = (_a = message === null || message === void 0 ? void 0 : message.outputs) === null || _a === void 0 ? void 0 : _a.objects) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c[codeField];
|
|
154
155
|
}
|
|
155
|
-
exports.getCurrentCodeByTaskId = getCurrentCodeByTaskId;
|
|
@@ -14,7 +14,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
17
|
+
exports.default = Loading;
|
|
18
|
+
exports.AIRunningLoading = AIRunningLoading;
|
|
18
19
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
20
|
const Spinner_1 = __importDefault(require("@arcblock/ux/lib/Spinner"));
|
|
20
21
|
const material_1 = require("@mui/material");
|
|
@@ -22,7 +23,6 @@ function Loading(props) {
|
|
|
22
23
|
const { sx } = props, restProps = __rest(props, ["sx"]);
|
|
23
24
|
return ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ sx: Object.assign({ flex: 1, display: 'flex', justifyContent: 'center', alignItems: 'center', position: 'fixed', top: 0, left: 0, width: '100vw', height: '100vh', backgroundColor: 'rgba(255, 255, 255, 0.8)' }, sx) }, restProps, { children: (0, jsx_runtime_1.jsx)(Spinner_1.default, {}) })));
|
|
24
25
|
}
|
|
25
|
-
exports.default = Loading;
|
|
26
26
|
function AIRunningLoading(props) {
|
|
27
27
|
const { sx } = props, restProps = __rest(props, ["sx"]);
|
|
28
28
|
const animationTimeList = [
|
|
@@ -151,4 +151,3 @@ function AIRunningLoading(props) {
|
|
|
151
151
|
height, animationIterationCount: isLast ? 'infinite' : 1, animationFillMode: isLast ? 'forwards' : 'none' }, sx) }, restSkeletonProps)) }, index));
|
|
152
152
|
}) })));
|
|
153
153
|
}
|
|
154
|
-
exports.AIRunningLoading = AIRunningLoading;
|
|
@@ -23,6 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.default = UserQuestion;
|
|
26
27
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
27
28
|
const ClickToCopy_1 = __importStar(require("@arcblock/ux/lib/ClickToCopy"));
|
|
28
29
|
const material_1 = require("@mui/material");
|
|
@@ -63,4 +64,3 @@ function UserQuestion({ question }) {
|
|
|
63
64
|
}, 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 }) }) }) }));
|
|
64
65
|
} }) })] }));
|
|
65
66
|
}
|
|
66
|
-
exports.default = UserQuestion;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.V0RuntimeProvider = V0RuntimeProvider;
|
|
4
|
+
exports.useV0RuntimeContext = useV0RuntimeContext;
|
|
4
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
6
|
const material_1 = require("@mui/material");
|
|
6
7
|
const react_1 = require("react");
|
|
@@ -46,7 +47,6 @@ function V0RuntimeProvider({ children }) {
|
|
|
46
47
|
}), [setCurrentMessageTaskId, currentMessageTaskId, propertiesValueMap, setPropertiesValueMap, isMobile]);
|
|
47
48
|
return (0, jsx_runtime_1.jsx)(context.Provider, { value: state, children: children });
|
|
48
49
|
}
|
|
49
|
-
exports.V0RuntimeProvider = V0RuntimeProvider;
|
|
50
50
|
function useV0RuntimeContext() {
|
|
51
51
|
const current = (0, react_1.useContext)(context);
|
|
52
52
|
if (!current) {
|
|
@@ -54,4 +54,3 @@ function useV0RuntimeContext() {
|
|
|
54
54
|
}
|
|
55
55
|
return current;
|
|
56
56
|
}
|
|
57
|
-
exports.useV0RuntimeContext = useV0RuntimeContext;
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.useAgentState =
|
|
12
|
+
exports.useAgentState = useAgentState;
|
|
13
13
|
const zustand_1 = require("zustand");
|
|
14
14
|
const immer_1 = require("zustand/middleware/immer");
|
|
15
15
|
const agent_1 = require("../api/agent");
|
|
@@ -56,4 +56,3 @@ function useAgentState({ blockletDid, aid, working, }) {
|
|
|
56
56
|
}
|
|
57
57
|
return [state.agent, state];
|
|
58
58
|
}
|
|
59
|
-
exports.useAgentState = useAgentState;
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.useRuntimeState =
|
|
12
|
+
exports.useRuntimeState = useRuntimeState;
|
|
13
13
|
const react_1 = require("react");
|
|
14
14
|
const session_1 = require("../../../session");
|
|
15
15
|
const Runtime_1 = require("../contexts/Runtime");
|
|
@@ -45,4 +45,3 @@ function useRuntimeState() {
|
|
|
45
45
|
}), [authSession.user, exec, blockletDid, working, login]);
|
|
46
46
|
return { blockletDid, aid, working, agent, execute };
|
|
47
47
|
}
|
|
48
|
-
exports.useRuntimeState = useRuntimeState;
|
|
@@ -27,7 +27,10 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
27
27
|
return t;
|
|
28
28
|
};
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
exports.
|
|
30
|
+
exports.createSessionState = void 0;
|
|
31
|
+
exports.useAutoLoadSessionState = useAutoLoadSessionState;
|
|
32
|
+
exports.useSessionState = useSessionState;
|
|
33
|
+
exports.useCurrentSessionState = useCurrentSessionState;
|
|
31
34
|
const aid_1 = require("@blocklet/ai-runtime/common/aid");
|
|
32
35
|
const react_1 = require("react");
|
|
33
36
|
const zustand_1 = require("zustand");
|
|
@@ -140,7 +143,7 @@ const createSessionState = ({ aid }) => {
|
|
|
140
143
|
state.currentSessionId = sessionId;
|
|
141
144
|
});
|
|
142
145
|
},
|
|
143
|
-
createSession: (...
|
|
146
|
+
createSession: (...args_1) => __awaiter(void 0, [...args_1], void 0, function* ({ name } = {}) {
|
|
144
147
|
const { created, sessions } = yield (0, session_1.createSession)({ aid, name });
|
|
145
148
|
set((state) => {
|
|
146
149
|
state.sessions = sessions;
|
|
@@ -155,7 +158,7 @@ const createSessionState = ({ aid }) => {
|
|
|
155
158
|
});
|
|
156
159
|
return created;
|
|
157
160
|
}),
|
|
158
|
-
deleteSession: (...
|
|
161
|
+
deleteSession: (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (args = {}) {
|
|
159
162
|
var _a;
|
|
160
163
|
const sessionId = args.sessionId || get().currentSessionId;
|
|
161
164
|
const autoSetCurrentSessionId = (_a = args.autoSetCurrentSessionId) !== null && _a !== void 0 ? _a : true;
|
|
@@ -170,7 +173,7 @@ const createSessionState = ({ aid }) => {
|
|
|
170
173
|
}
|
|
171
174
|
});
|
|
172
175
|
}),
|
|
173
|
-
clearSession: (...
|
|
176
|
+
clearSession: (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (args = {}) {
|
|
174
177
|
const sessionId = args.sessionId || get().currentSessionId;
|
|
175
178
|
if (!sessionId)
|
|
176
179
|
return;
|
|
@@ -185,8 +188,8 @@ const createSessionState = ({ aid }) => {
|
|
|
185
188
|
s.messageLoading = undefined;
|
|
186
189
|
});
|
|
187
190
|
}),
|
|
188
|
-
loadMoreMessages: (...
|
|
189
|
-
var
|
|
191
|
+
loadMoreMessages: (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (args = {}) {
|
|
192
|
+
var _a, _b;
|
|
190
193
|
const sessionId = args.sessionId || get().currentSessionId;
|
|
191
194
|
const limit = args.limit || GET_MESSAGES_LIMIT;
|
|
192
195
|
if (!sessionId)
|
|
@@ -205,7 +208,7 @@ const createSessionState = ({ aid }) => {
|
|
|
205
208
|
try {
|
|
206
209
|
const result = yield (0, message_1.getMessages)({
|
|
207
210
|
sessionId: s.session.id,
|
|
208
|
-
before: (
|
|
211
|
+
before: (_b = (_a = s.messages) === null || _a === void 0 ? void 0 : _a.slice(-1)[0]) === null || _b === void 0 ? void 0 : _b.id,
|
|
209
212
|
orderDirection: GET_MESSAGES_ORDER_DIRECTION,
|
|
210
213
|
limit,
|
|
211
214
|
});
|
|
@@ -235,18 +238,18 @@ const createSessionState = ({ aid }) => {
|
|
|
235
238
|
for (let i = 0; i < sessions.length; i += groupSize) {
|
|
236
239
|
const group = sessions.slice(i, i + groupSize);
|
|
237
240
|
// eslint-disable-next-line no-await-in-loop
|
|
238
|
-
yield Promise.all(group.map((
|
|
239
|
-
var
|
|
241
|
+
yield Promise.all(group.map((_a) => __awaiter(void 0, [_a], void 0, function* ({ id: sessionId }) {
|
|
242
|
+
var _b, _c;
|
|
240
243
|
// if messages is empty, load latest message
|
|
241
|
-
if (!((
|
|
244
|
+
if (!((_c = (_b = sessionMap === null || sessionMap === void 0 ? void 0 : sessionMap[sessionId]) === null || _b === void 0 ? void 0 : _b.messages) === null || _c === void 0 ? void 0 : _c.length)) {
|
|
242
245
|
yield get().loadMoreMessages({ sessionId, limit: 1 });
|
|
243
246
|
}
|
|
244
247
|
})));
|
|
245
248
|
}
|
|
246
249
|
}),
|
|
247
|
-
execute: (
|
|
248
|
-
var
|
|
249
|
-
var { blockletDid, aid, working, parameters, onResponseStart } =
|
|
250
|
+
execute: (_a) => __awaiter(void 0, void 0, void 0, function* () {
|
|
251
|
+
var _b, e_1, _c, _d;
|
|
252
|
+
var { blockletDid, aid, working, parameters, onResponseStart } = _a, args = __rest(_a, ["blockletDid", "aid", "working", "parameters", "onResponseStart"]);
|
|
250
253
|
const sessionId = args.sessionId ||
|
|
251
254
|
get().currentSessionId ||
|
|
252
255
|
(yield get().createSession({
|
|
@@ -272,10 +275,10 @@ const createSessionState = ({ aid }) => {
|
|
|
272
275
|
});
|
|
273
276
|
let responseStarted = false;
|
|
274
277
|
try {
|
|
275
|
-
for (var
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
const value =
|
|
278
|
+
for (var _e = true, stream_1 = __asyncValues(stream), stream_1_1; stream_1_1 = yield stream_1.next(), _b = stream_1_1.done, !_b; _e = true) {
|
|
279
|
+
_d = stream_1_1.value;
|
|
280
|
+
_e = false;
|
|
281
|
+
const value = _d;
|
|
279
282
|
if (!responseStarted) {
|
|
280
283
|
responseStarted = true;
|
|
281
284
|
onResponseStart === null || onResponseStart === void 0 ? void 0 : onResponseStart();
|
|
@@ -339,7 +342,7 @@ const createSessionState = ({ aid }) => {
|
|
|
339
342
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
340
343
|
finally {
|
|
341
344
|
try {
|
|
342
|
-
if (!
|
|
345
|
+
if (!_e && !_b && (_c = stream_1.return)) yield _c.call(stream_1);
|
|
343
346
|
}
|
|
344
347
|
finally { if (e_1) throw e_1.error; }
|
|
345
348
|
}
|
|
@@ -379,12 +382,10 @@ function useAutoLoadSessionState(...args) {
|
|
|
379
382
|
state.getState().load(...args);
|
|
380
383
|
}, [state, currentSessionId]);
|
|
381
384
|
}
|
|
382
|
-
exports.useAutoLoadSessionState = useAutoLoadSessionState;
|
|
383
385
|
function useSessionState(selector) {
|
|
384
386
|
const { aid } = (0, Runtime_1.useRuntimeContext)();
|
|
385
387
|
return (0, react_1.useMemo)(() => (0, exports.createSessionState)({ aid }), [aid])(selector);
|
|
386
388
|
}
|
|
387
|
-
exports.useSessionState = useSessionState;
|
|
388
389
|
function useCurrentSessionState(selector) {
|
|
389
390
|
return useSessionState((state) => {
|
|
390
391
|
var _a;
|
|
@@ -392,4 +393,3 @@ function useCurrentSessionState(selector) {
|
|
|
392
393
|
return selector(s);
|
|
393
394
|
});
|
|
394
395
|
}
|
|
395
|
-
exports.useCurrentSessionState = useCurrentSessionState;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.USER_INPUT_PARAMETER_TYPES = void 0;
|
|
4
|
+
exports.isValidInput = isValidInput;
|
|
4
5
|
exports.USER_INPUT_PARAMETER_TYPES = ['string', 'number', 'select', 'language'];
|
|
5
6
|
function isValidInput(input) {
|
|
6
7
|
return !!input.key && exports.USER_INPUT_PARAMETER_TYPES.includes(input.type || 'string');
|
|
7
8
|
}
|
|
8
|
-
exports.isValidInput = isValidInput;
|
|
@@ -9,7 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.downloadImage = downloadImage;
|
|
13
|
+
exports.convertImageToBlob = convertImageToBlob;
|
|
13
14
|
function downloadImage(_a) {
|
|
14
15
|
return __awaiter(this, arguments, void 0, function* ({ url }) {
|
|
15
16
|
return new Promise((resolve, reject) => {
|
|
@@ -20,7 +21,6 @@ function downloadImage(_a) {
|
|
|
20
21
|
});
|
|
21
22
|
});
|
|
22
23
|
}
|
|
23
|
-
exports.downloadImage = downloadImage;
|
|
24
24
|
function convertImageToBlob(image) {
|
|
25
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
26
26
|
return new Promise((resolve, reject) => {
|
|
@@ -38,4 +38,3 @@ function convertImageToBlob(image) {
|
|
|
38
38
|
});
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
|
-
exports.convertImageToBlob = convertImageToBlob;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = mapRight;
|
|
3
4
|
function mapRight(array, fn) {
|
|
4
5
|
const result = new Array(array.length);
|
|
5
6
|
for (let i = array.length - 1; i >= 0; i--) {
|
|
@@ -7,4 +8,3 @@ function mapRight(array, fn) {
|
|
|
7
8
|
}
|
|
8
9
|
return result;
|
|
9
10
|
}
|
|
10
|
-
exports.default = mapRight;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getOutputVariableInitialValue =
|
|
3
|
+
exports.getOutputVariableInitialValue = getOutputVariableInitialValue;
|
|
4
4
|
function getOutputVariableInitialValue(agent, output) {
|
|
5
5
|
var _a, _b;
|
|
6
6
|
return (_b = (_a = agent.outputVariables) === null || _a === void 0 ? void 0 : _a.find((i) => i.name === output)) === null || _b === void 0 ? void 0 : _b.initialValue;
|
|
7
7
|
}
|
|
8
|
-
exports.getOutputVariableInitialValue = getOutputVariableInitialValue;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createCachedStore =
|
|
3
|
+
exports.createCachedStore = createCachedStore;
|
|
4
4
|
const STATES = {};
|
|
5
5
|
function createCachedStore(key, creator) {
|
|
6
6
|
var _a;
|
|
7
7
|
(_a = STATES[key]) !== null && _a !== void 0 ? _a : (STATES[key] = creator());
|
|
8
8
|
return STATES[key];
|
|
9
9
|
}
|
|
10
|
-
exports.createCachedStore = createCachedStore;
|
package/lib/cjs/builtin/call.js
CHANGED
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.call =
|
|
12
|
+
exports.call = call;
|
|
13
13
|
const utils_1 = require("./utils");
|
|
14
14
|
function call(input) {
|
|
15
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -41,4 +41,3 @@ function call(input) {
|
|
|
41
41
|
});
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
|
-
exports.call = call;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Icon =
|
|
3
|
+
exports.Icon = Icon;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("@iconify/react");
|
|
6
6
|
const material_1 = require("@mui/material");
|
|
7
7
|
function Icon(props) {
|
|
8
8
|
return (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ component: react_1.Icon }, props));
|
|
9
9
|
}
|
|
10
|
-
exports.Icon = Icon;
|
|
11
10
|
exports.default = Icon;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.useHeaderState = void 0;
|
|
4
|
+
exports.useHeader = useHeader;
|
|
4
5
|
const immer_1 = require("immer");
|
|
5
6
|
const react_1 = require("react");
|
|
6
7
|
const zustand_1 = require("zustand");
|
|
@@ -45,4 +46,3 @@ function useHeader(creator, deps) {
|
|
|
45
46
|
return () => exports.useHeaderState.getState().delete(creator);
|
|
46
47
|
}, deps);
|
|
47
48
|
}
|
|
48
|
-
exports.useHeader = useHeader;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useSessionContext =
|
|
3
|
+
exports.useSessionContext = useSessionContext;
|
|
4
4
|
const Session_1 = require("@arcblock/did-connect/lib/Session");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
function useSessionContext() {
|
|
7
7
|
return (0, react_1.useContext)(Session_1.SessionContext);
|
|
8
8
|
}
|
|
9
|
-
exports.useSessionContext = useSessionContext;
|
package/lib/cjs/builtin/utils.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getQuery = exports.withQuery = exports.joinURL = void 0;
|
|
4
|
+
exports.getComponentMountPoint = getComponentMountPoint;
|
|
4
5
|
var ufo_1 = require("ufo");
|
|
5
6
|
Object.defineProperty(exports, "joinURL", { enumerable: true, get: function () { return ufo_1.joinURL; } });
|
|
6
7
|
Object.defineProperty(exports, "withQuery", { enumerable: true, get: function () { return ufo_1.withQuery; } });
|
|
@@ -13,4 +14,3 @@ function getComponentMountPoint(name) {
|
|
|
13
14
|
}
|
|
14
15
|
return (_b = (_a = globalThis.blocklet) === null || _a === void 0 ? void 0 : _a.componentMountPoints.find((i) => i.name === name || i.did === name)) === null || _b === void 0 ? void 0 : _b.mountPoint;
|
|
15
16
|
}
|
|
16
|
-
exports.getComponentMountPoint = getComponentMountPoint;
|
|
@@ -34,6 +34,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
34
34
|
return t;
|
|
35
35
|
};
|
|
36
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.default = BlockletReactComponentRenderer;
|
|
37
38
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
38
39
|
const react_1 = __importStar(require("react"));
|
|
39
40
|
const utils_1 = require("../../builtin/utils");
|
|
@@ -53,7 +54,6 @@ function BlockletReactComponentRenderer(_a) {
|
|
|
53
54
|
const C = loadComponent(url);
|
|
54
55
|
return (0, jsx_runtime_1.jsx)(C, Object.assign({}, props.props));
|
|
55
56
|
}
|
|
56
|
-
exports.default = BlockletReactComponentRenderer;
|
|
57
57
|
const COMPONENTS_CACHE = {};
|
|
58
58
|
function loadComponent(url) {
|
|
59
59
|
var _a;
|
|
@@ -11,7 +11,8 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
return t;
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.
|
|
14
|
+
exports.DevProvider = DevProvider;
|
|
15
|
+
exports.useDev = useDev;
|
|
15
16
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
17
|
const react_1 = require("react");
|
|
17
18
|
const devContext = (0, react_1.createContext)(undefined);
|
|
@@ -19,8 +20,6 @@ function DevProvider(_a) {
|
|
|
19
20
|
var { dev } = _a, props = __rest(_a, ["dev"]);
|
|
20
21
|
return (0, jsx_runtime_1.jsx)(devContext.Provider, Object.assign({ value: dev }, props));
|
|
21
22
|
}
|
|
22
|
-
exports.DevProvider = DevProvider;
|
|
23
23
|
function useDev() {
|
|
24
24
|
return (0, react_1.useContext)(devContext);
|
|
25
25
|
}
|
|
26
|
-
exports.useDev = useDev;
|
|
@@ -28,6 +28,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
28
28
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
29
29
|
};
|
|
30
30
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
exports.default = CustomComponentRenderer;
|
|
31
32
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
32
33
|
const material_1 = require("@mui/material");
|
|
33
34
|
const react_error_boundary_1 = require("react-error-boundary");
|
|
@@ -44,7 +45,6 @@ function CustomComponentRenderer(_a) {
|
|
|
44
45
|
const BuiltinComponent = BuiltinComponents[props.componentId];
|
|
45
46
|
return ((0, jsx_runtime_1.jsx)(react_error_boundary_1.ErrorBoundary, { FallbackComponent: (props === null || props === void 0 ? void 0 : props.fallbackRender) || ErrorView, children: (0, jsx_runtime_1.jsx)(DevProvider_1.DevProvider, { dev: dev !== null && dev !== void 0 ? dev : inheritedDev, children: BuiltinComponent ? ((0, jsx_runtime_1.jsx)(BuiltinComponent, Object.assign({}, props))) : ((0, jsx_runtime_1.jsx)(ComponentRenderer, Object.assign({}, props, { instanceId: (_b = props.instanceId) !== null && _b !== void 0 ? _b : props.componentId }))) }) }));
|
|
46
47
|
}
|
|
47
|
-
exports.default = CustomComponentRenderer;
|
|
48
48
|
const BuiltinComponents = {
|
|
49
49
|
'blocklet-react-component': BlockletReactComponentRenderer_1.default,
|
|
50
50
|
};
|
|
@@ -46,7 +46,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
46
46
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
47
47
|
};
|
|
48
48
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
|
-
exports.
|
|
49
|
+
exports.customComponentStates = void 0;
|
|
50
|
+
exports.useComponent = useComponent;
|
|
51
|
+
exports.transpileAndLoadScript = transpileAndLoadScript;
|
|
50
52
|
const set_1 = __importDefault(require("lodash/set"));
|
|
51
53
|
const react_1 = require("react");
|
|
52
54
|
const zustand_1 = require("zustand");
|
|
@@ -154,7 +156,6 @@ function useComponent({ instanceId, componentId, properties, locale, dev }) {
|
|
|
154
156
|
error: transpile === null || transpile === void 0 ? void 0 : transpile.error,
|
|
155
157
|
};
|
|
156
158
|
}
|
|
157
|
-
exports.useComponent = useComponent;
|
|
158
159
|
const COMPONENT_LOADER_MAP = {};
|
|
159
160
|
function usePreloadComponent({ instanceId, componentId, properties, locale, dev }) {
|
|
160
161
|
var _a;
|
|
@@ -252,4 +253,3 @@ function transpileAndLoadScript(script) {
|
|
|
252
253
|
return Promise.resolve(`${url}`).then(s => __importStar(require(s)));
|
|
253
254
|
});
|
|
254
255
|
}
|
|
255
|
-
exports.transpileAndLoadScript = transpileAndLoadScript;
|